diff options
author | Rostislav Beneš <r.dee.b.b@gmail.com> | 2017-10-08 21:42:22 +0200 |
---|---|---|
committer | Rostislav Beneš <r.dee.b.b@gmail.com> | 2017-10-22 21:01:40 +0200 |
commit | ba4cefe4ae70cfb9121281f508ed5d9fa9dbc662 (patch) | |
tree | 01863d0fcf1edc435bd3ccc998f8262a7486a21e /pkgs/development/libraries/aspell | |
parent | 6d86fcb86de75a307684cf2e6b8a518bd458427c (diff) |
aspell: added new patch data-dirs-from-nix-profiles.patch
Aspell will search for dictionaries in all nix profiles even when used as library.
Setting data-dir or dict-dir in ASPELL_CONF will disable this behavior.
Diffstat (limited to 'pkgs/development/libraries/aspell')
3 files changed, 46 insertions, 23 deletions
diff --git a/pkgs/development/libraries/aspell/aspell-with-dicts.nix b/pkgs/development/libraries/aspell/aspell-with-dicts.nix index 0739ad333df3..fd5ccf9696cc 100644 --- a/pkgs/development/libraries/aspell/aspell-with-dicts.nix +++ b/pkgs/development/libraries/aspell/aspell-with-dicts.nix @@ -1,5 +1,9 @@ # Create a derivation that contains aspell and selected dictionaries. # Composition is done using `pkgs.buildEnv`. +# Beware of that `ASPELL_CONF` used by this derivation is not always +# respected by libaspell (#28815) and in some cases, when used as +# dependency by another derivation, the passed dictionaries will be +# missing. However, invoking aspell directly should be fine. { aspell , aspellDicts diff --git a/pkgs/development/libraries/aspell/data-dirs-from-nix-profiles.patch b/pkgs/development/libraries/aspell/data-dirs-from-nix-profiles.patch new file mode 100644 index 000000000000..c19827ba93e4 --- /dev/null +++ b/pkgs/development/libraries/aspell/data-dirs-from-nix-profiles.patch @@ -0,0 +1,38 @@ +diff --git a/common/info.cpp b/common/info.cpp +index 8291cc7..6216326 100644 +--- a/common/info.cpp ++++ b/common/info.cpp +@@ -36,6 +36,7 @@ + #include "strtonum.hpp" + #include "lock.hpp" + #include "string_map.hpp" ++#include "file_util.hpp" + + #include "gettext.h" + +@@ -495,6 +496,25 @@ namespace acommon { + lst.clear(); + lst.add(config->retrieve("data-dir")); + lst.add(config->retrieve("dict-dir")); ++ if (config->lookup("data-dir") == NULL && config->lookup("dict-dir") == NULL) { ++ const char* cprofiles = getenv("NIX_PROFILES"); ++ if (cprofiles != NULL) { ++ char* profiles = strdup(cprofiles); ++ char* profile = profiles; ++ char* end = profile; ++ while (*end != '\0') { ++ if (*end == ' ') { ++ *end = '\0'; ++ lst.add(add_possible_dir(profile, "lib/aspell")); ++ profile = ++end; ++ } else { ++ ++end; ++ } ++ } ++ lst.add(add_possible_dir(profile, "lib/aspell")); ++ free(profiles); ++ } ++ } + } + + DictExt::DictExt(ModuleInfo * m, const char * e) diff --git a/pkgs/development/libraries/aspell/default.nix b/pkgs/development/libraries/aspell/default.nix index e69bbe0d2f2b..0f6f5e8dd147 100644 --- a/pkgs/development/libraries/aspell/default.nix +++ b/pkgs/development/libraries/aspell/default.nix @@ -1,4 +1,5 @@ -{stdenv, fetchurl, perl}: +{stdenv, fetchurl, perl +, searchNixProfiles ? true}: stdenv.mkDerivation rec { name = "aspell-0.60.6.1"; @@ -10,6 +11,8 @@ stdenv.mkDerivation rec { patchPhase = '' patch interfaces/cc/aspell.h < ${./clang.patch} + '' + stdenv.lib.optionalString searchNixProfiles '' + patch -p1 < ${./data-dirs-from-nix-profiles.patch} ''; buildInputs = [ perl ]; @@ -23,28 +26,6 @@ stdenv.mkDerivation rec { ); ''; - 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"; homepage = http://aspell.net/; |