How to add dictionary to arbitrary package?


I wrote a package for a commandline tool, which expects a dictionary file. By default the tool expects the dict file in /usr/share/dict/american-english. On a conventional linux distro like debian this comes with the package wamerican-insane, which itself fetches it from the aspell project afaik.

Now, I could just add the dict file to the flake. But the tool in question would still expect it in the said location. Although it has an option with which the user could specify any dict file, it would be better - from a packager point of view - to provide some kind of default.

In this particular case I am also the maintainer of the tool, so I could just add a build flag so that another default location could be provided at build time. However, what would I do, if I’m not the maintainer? How do “nix people” solve these kind of problems usually?

Thanks in advance,

1 Like

there are some solutions but you either solve it at the system level via nixos options or at the package level via overrides.
in the system level with nixos options you can just create a symlink to the actual file in the store, if that is impossible for some reason you can alternatively use cgroups similar to how Steam’s Simulated FHS works.
for the package level you actually make 2 packages one which provides the unwrapped binary and another which calls the unwrapped binary with the appropriate CLI options to use the dictionaries provided this is extensively used with Vim and Neovim. obviously this won’t work if you aren’t using callPackage because then you can’t .override the wrapped package extending with more dictionaries.