New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
weechat: allow specifying dicts for spellchecking #38393
Conversation
Previously it wasn't possible to build weechat without python support as the `weechat.python` attribute was used in the config'
Use as so: ```nix weechat = super.weechat.override { weechatEnchantHunspellDicts = [pkgs.hunspellDicts.en-us]; } ``` ```nix weechat = super.weechat.override { weechatAspellDicts = [pkgs.aspellDicts.en]; } ```
Works for aspell and myspell (hunspell) when using enchant. See NixOS/nixpkgs#38393 and NixOS/nixpkgs#34308 for motivation
Related PR #34856 |
@@ -26,6 +34,16 @@ let | |||
]; | |||
enabledPlugins = builtins.filter (p: p.enabled) plugins; | |||
|
|||
aspellDictEnv = buildEnv{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use aspellWithDicts
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially tried using aspellWithDicts
and hunspellWithDicts
, however these seem to just wrap the binaries, and don't change the behavior of the libraries themselves.
I could use it to create the environment however, I don't think it would make any difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to let one override the aspell
derivation and pass in one that has required dicts (e.g. using aspellWithDicts
than having the dicts as an option. This way it is guaranteed the dicts match with the aspell build.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I don't think the same can be done for the enchant/hunspell pair without a bit more plumbing though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FRidh done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enchant will pick up hunspell dictionaries from XDG_DATA_DIRS
. Why not just install them globally with an enchant module, instead of overriding each package separately?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just install them globally with an enchant module, instead of overriding each package separately?
One may want to be explicit about what dictionaries are used.
But I agree with you; in practice one likely just wants what is provided by the system (XDG_DATA_DIRS
).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That didn't seem to be working in my case, which motivated this PR. I think there's value in having this all self contained though, indeed I'm currently running weechat on a server with a user without XDG_DATA_DIRS.
I do agree that patching each user of enchant
isn't a perfect solution though. Installing them globally doesn't quite fit the nix philosophy though. A much better change would be to patch aspell so that not only the binary can find the dictionaries in aspellWithDicts
but the library can too (and similarly for hunspell).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One small downside of that is that spelling dictionaries seem to be a fairly fragile part of nixpkgs, and meddling with aspell/hunspell internals might have to be done carefully.
Use like this now: ```nix weechat = super.weechat.override { aspell = pkgs.aspellWithDicts (ps: [ps.en]); }; ```
I can imagine someone using a specific program only for communication in a single language and not needing other dictionaries installed system-wide but I think this use case is quite rare and not really worth the added complexity of package expressions. This is exactly what environment is for. 👎 |
This is great! |
In case it’s useful to anyone else, here’s a way to get this same kind of customizability for WeeChat and Aspell without patching nixpkgs. Add a section like the following to the { pkgs }:
{
packageOverrides = pkgs: rec {
weechat = let
aspell = pkgs.aspellWithDicts (dicts:
with dicts; [ en en-computers en-science ]
);
in (pkgs.weechat.overrideAttrs (oldAttrs: {
buildInputs = (oldAttrs.buildInputs or []) ++ [ aspell ];
})).override {
configure = { availablePlugins, ... }: {
init = ''
/set env ASPELL_CONF "dict-dir ${aspell}/lib/aspell"
'';
};
};
};
} This example selects the |
@bdesham Looks great, I'm using this now |
Hello, I'm a bot and I thank you in the name of the community for your contributions. Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human. If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do: If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list. If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past. If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments. Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel. |
Closing as @bdesham's solution is neater. |
Use as so: