diff options
author | Leandro Lisboa Penz <lpenz@lpenz.org> | 2017-03-28 22:56:12 +0100 |
---|---|---|
committer | Leandro Lisboa Penz <lpenz@lpenz.org> | 2017-04-10 22:14:29 +0100 |
commit | ce6b5b8673967d45aead38180d65288460a14640 (patch) | |
tree | b7c4f003c16b2b4a92e01f0fdf2d3b3506201c2c /pkgs/development/libraries/aspell | |
parent | f19547b7fec46cca66af94c3680bc571ec44fc6e (diff) |
aspell: set default aspell data-dir if ASPELL_CONF is not set
if the user didn't set ASPELL_CONF, use it to point to the dictionary location by first looking at NIX_PROFILE directories and then using $HOME/.nix-profile. See NixOS/nixpkgs#1000
Diffstat (limited to 'pkgs/development/libraries/aspell')
-rw-r--r-- | pkgs/development/libraries/aspell/default.nix | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/pkgs/development/libraries/aspell/default.nix b/pkgs/development/libraries/aspell/default.nix index 5af340bef07ab..e69bbe0d2f2ba 100644 --- a/pkgs/development/libraries/aspell/default.nix +++ b/pkgs/development/libraries/aspell/default.nix @@ -23,12 +23,27 @@ stdenv.mkDerivation rec { ); ''; - # Note: Users should define the `ASPELL_CONF' environment variable to - # `data-dir $HOME/.nix-profile/lib/aspell/' so that they can access - # dictionaries installed in their profile. - # - # We can't use `$out/etc/aspell.conf' for that purpose since Aspell - # doesn't expand environment variables such as `$HOME'. + postInstall = '' + local prog="$out/bin/aspell" + local hidden="$out/bin/.aspell-wrapped" + mv "$prog" "$hidden" + cat > "$prog" <<END + #! $SHELL -e + if [ -z "\$ASPELL_CONF" ]; then + for p in \$NIX_PROFILES; do + if [ -d "\$p/lib/aspell" ]; then + ASPELL_CONF="data-dir \$p/lib/aspell" + fi + done + if [ -z "\$ASPELL_CONF" ] && [ -d "\$HOME/.nix-profile/lib/aspell" ]; then + ASPELL_CONF="data-dir \$HOME/.nix-profile/lib/aspell" + fi + export ASPELL_CONF + fi + exec "$hidden" "\$@" + END + chmod +x "$prog" + ''; meta = { description = "Spell checker for many languages"; |