Atom editor can't find hunspell dictionary

Hi, I am using NixOS 19.03.

The Atom editor has a spell checker. This is a core package (built-in package management) of the editor. When I start Atom, I get the following message.

warning

The spell checker apparently uses hunspell dictionaries. For other Linux distributions, users are advised to install the correct hunspell dictionary. So, I installed hunspell and hunspellDicts.de-de via /etc/nixos/configuration.nix. I had already guessed that that wouldn’t work and I was not surprised when Atom still could not find the dictionary.

The hunspell command itself can’t find the dictionary:

> hunspell -D
SEARCH PATH:
.::/usr/share/hunspell:/usr/share/myspell:/usr/share/myspell/dicts:/Library/Spelling:/home/martin/.openoffice.org/3/user/wordbook:/home/martin/.openoffice.org2/user/wordbook:/home/martin/.openoffice.org2.0/user/wordbook:/home/martin/Library/Spelling:/opt/openoffice.org/basis3.0/share/dict/ooo:/usr/lib/openoffice.org/basis3.0/share/dict/ooo:/opt/openoffice.org2.4/share/dict/ooo:/usr/lib/openoffice.org2.4/share/dict/ooo:/opt/openoffice.org2.3/share/dict/ooo:/usr/lib/openoffice.org2.3/share/dict/ooo:/opt/openoffice.org2.2/share/dict/ooo:/usr/lib/openoffice.org2.2/share/dict/ooo:/opt/openoffice.org2.1/share/dict/ooo:/usr/lib/openoffice.org2.1/share/dict/ooo:/opt/openoffice.org2.0/share/dict/ooo:/usr/lib/openoffice.org2.0/share/dict/ooo
AVAILABLE DICTIONARIES (path is not mandatory for -d option):

I suppose I could download the dictionary and put it into /home/martin/.openoffice.org/3/user/wordbook, for example. I then could point the Atom spell-checker to that directory. That should probably work. But if I wanted to download software and resources manually, I would use Windows :wink:. I hope there is a more idiomatic way that leverages Nix.

Could anyone point me in the general direction of a solution? Do I need to hack on the Nix expression for the atom package?

Edit: spelling

I think the best way to make it work on 19.03 is to set this in your profile:

export DICPATH=$HOME/.nix-profile/share/hunspell

This should work out of the box in the future without setting DICPATH Lookup hunspell dictionaries in XDG_DATA_DIRS by matthewbauer · Pull Request #65349 · NixOS/nixpkgs · GitHub.

and then install it to your profile with:

nix-env -iA nixos.hunspellDicts.de-de
1 Like

Thanks for your reply. If I set DICPATH to the correct path, hunspell is able to find the dictionary.

I learned that the dictionaries are available at /run/current-system/sw/share/hunspell, if they are installed declaratively via /etc/nixos/configuration.nix. So, I am setting DICPATH to that instead:

export DICPATH=/run/current-system/sw/share/hunspell

Unfortunately, the Atom spell checker does not use DICPATH or XDG_DATA_DIRS. But that’s an issue of the spell checker. For now, I can workaround that by adding /run/current-system/sw/share/hunspell to the list of paths the spell checker searches for dictionaries.

Sorry for reviving old thread but does installing hunspell dicts populate /run/current-system/sw/share/hunspell? Installing neither hunspellWithDicts [...] nor hunspellDicts.xx-yy via environment.systemPackages results in that directory existing nixpkgs on my system. Looking at hunspell pacakge in nixpkgs git, there don’t seem to be recent changes in this area.

Weirdly, installing via nix-env -i populates ~/.nix-profile/share/hunspell.

I’m trying to add spellchecking support to the LibreOffice package but am a bit lost wrt how to pass the installed dictionaries to the program.

Edit: Contents of /run/current-system/sw are determined by option environment.pathsToLink. Some desktop environments (lumina, mate, pantheon, plasma, lxqt, gnome3) add "/share" to the list which recursively includes /share/hunspell. If you don’t use one of those desktops then /run/current-system/sw/share/hunspell is not created.

1 Like

Kudos for finding the cause. I just want to confirm that I have been and am using Gnome 3.

1 Like

Does it mean that, if I don’t use these DE, I need to set environment.pathsToLink option manually? If so, what should be the value for hunspell to appear in …/share/?

You would use pathsToLink = [ "share/hunspell" ]; or possibly pathsToLink = [ "share/myspell/dicts" ];. And you need to add hunspellDicts.xx-yy to environment.systemPackages, not hunspellWithDicts […]. The latter derivation itself does not contain any dictionaries, only a hunspell executable wrapped so it can use the dictionaries specified.

1 Like