From cb01efd267c6ab4d9e15693abf6d1b2aa03e7a4b Mon Sep 17 00:00:00 2001 From: Daniel Fainberg Date: Wed, 16 Sep 2026 11:14:32 +0200 Subject: [PATCH] feat(dictionaries): add hunspell dictionary module --- modules/dictionaries.nix | 53 ++++++++++++++++++++++++++++++++++++++++ modules/home.nix | 2 +- 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 modules/dictionaries.nix diff --git a/modules/dictionaries.nix b/modules/dictionaries.nix new file mode 100644 index 0000000..786349b --- /dev/null +++ b/modules/dictionaries.nix @@ -0,0 +1,53 @@ +# Hunspell dictionaries, joined into one directory so anything needing a +# dictionary *path* can be pointed at a single store path. +# +# Two consumers, two mechanisms: +# - LibreOffice needs nothing beyond the package being installed: its wrapper +# scans `share/hunspell` in every NIX_PROFILES entry. +# - Gecko apps (LibreWolf, Thunderbird) need `spellchecker.dictionary_path` +# set explicitly — there is no /usr/share/hunspell on NixOS and wrapFirefox +# wires up nothing itself. Point that pref at `local.dictionaries.path`. +# +# Chromium-based browsers are NOT served by this: they ignore hunspell and +# fetch their own dictionaries, selected by enterprise policy. +# +# Which languages is a personal choice, so the default is empty; a consumer sets +# `local.dictionaries.packages = [ pkgs.hunspellDicts.de_DE ];`. en-US ships +# inside Firefox/Thunderbird already and does not need listing for those. +{ config, lib, pkgs, ... }: + +let + cfg = config.local.dictionaries; + + joined = pkgs.symlinkJoin { + name = "hunspell-dicts"; + paths = cfg.packages; + }; +in +{ + options.local.dictionaries = { + packages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + example = lib.literalExpression "[ pkgs.hunspellDicts.de_DE ]"; + description = '' + Hunspell dictionary packages to install and expose via + `local.dictionaries.path`. + ''; + }; + + path = lib.mkOption { + type = lib.types.str; + readOnly = true; + description = '' + Directory holding every `packages` dictionary. Feed this to + `spellchecker.dictionary_path` in Gecko apps. + ''; + }; + }; + + config = { + local.dictionaries.path = "${joined}/share/hunspell"; + home.packages = lib.optional (cfg.packages != [ ]) joined; + }; +} diff --git a/modules/home.nix b/modules/home.nix index 29067b0..761ab34 100644 --- a/modules/home.nix +++ b/modules/home.nix @@ -125,7 +125,7 @@ let ''; in { - imports = [ ./gpg.nix ./media.nix ./texlive.nix ./librewolf.nix ./mc.nix ./mime.nix ./hyprland-workspaces.nix ./nvim.nix ]; + imports = [ ./gpg.nix ./media.nix ./texlive.nix ./librewolf.nix ./mc.nix ./mime.nix ./hyprland-workspaces.nix ./nvim.nix ./dictionaries.nix ]; # Put ~/.local/bin (the XDG user-bin dir) on PATH so hand-dropped scripts run # by name without wiring each through nix.