Installing aspell dictionaries with Nixpkgs

One might assume installing aspell and associated dictionaries with Nixpkgs can be accomplished using the familiar approach of listing desired packages.

{ pkgs, ... }: {
  config = {
    environment.systemPackages = with pkgs; [
      aspell
      aspellDicts.en
      aspellDicts.en-computers
      aspellDicts.en-science
    ];
  }
}

This will install aspell and the desired dictionaries, but they’ll be isolated and cause errors when attempting to adequately express yourself in Emacs.

Starting new Ispell process aspell with default dictionary...done
ispell-init-process: Error: No word lists can be found for the language "en_US".

The trick is to install aspell and your desired dictionaries using the provided aspellWithDicts:

environment.systemPackages = with pkgs; [
  (aspellWithDicts (dicts: with dicts; [en en-computers en-science]))
];

With that we should see a lengthy list of dictionaries available to aspell:

$ aspell dicts
en
en-variant_0
en-variant_1
en-variant_2
en-w_accents
en-wo_accents
en_AU
en_AU-variant_0
en_AU-variant_1
en_AU-w_accents
en_AU-wo_accents
en_CA
en_CA-variant_0
en_CA-variant_1
en_CA-w_accents
en_CA-wo_accents
en_GB
en_GB-ise
en_GB-ise-w_accents
en_GB-ise-wo_accents
en_GB-ize
en_GB-ize-w_accents
en_GB-ize-wo_accents
en_GB-variant_0
en_GB-variant_1
en_GB-w_accents
en_GB-wo_accents
en_US
en_US-variant_0
en_US-variant_1
en_US-w_accents
en_US-wo_accents