nixnixos

Aspell dictionaries missing when installed into nix-shell


When I install the Aspell package with the Aspell dictionary for English into my global env using Nix on Mac OSX:

$ nix-env -iA nixpkgs.aspell nixpkgs.aspellDicts.en

Then Aspell behaves as I would expect:

$ aspell dump dicts

en
en-variant_0
...

However if I install the packages into a nix-shell then the Dictionary does not appear to be correctly installed:

$ nix-shell -p aspell aspellDicts.en --pure

$ aspell dump dicts
# nothing printed

$ echo 'word lister to check' | aspell --list
Error: No word lists can be found for the language "en_US".

Each of the following variations produce the same problem behaviour:

Can anyone advise how to get this working?


Solution

  • The aspell binary is wrapped by NixPkgs, to provide the installation paths through ASPELL_CONF environment variable, if not already specified. (For details, cat -v result/bin/aspell)

    You can either specify ASPELL_CONF manually, or use the NIX_PROFILES environment variable. For example:

    $ nix-build -E 'with import <nixpkgs> {};
         buildEnv { name = "aspell-env"; paths = [aspell aspellDicts.en]; }'
    
    $ NIX_PROFILES=./result ./result/bin/aspell dump dicts
    en
    en-variant_0
    [...]
    en_US-wo_accents
    

    However, if you want to build a self-contained aspell install with dictionaries, you can use aspellWithDicts:

    nix-build -E 'with import <nixpkgs> {}; aspellWithDicts (d: [d.en])'
    

    This will hardcode the ASPELL_CONF, so you don't need to think of those environment variables again.