summary refs log tree commit diff
path: root/pkgs/development
diff options
context:
space:
mode:
authorFrederik Rietdijk <freddyrietdijk@fridh.nl>2017-10-23 07:47:11 +0200
committerGitHub <noreply@github.com>2017-10-23 07:47:11 +0200
commit891c3721edd9881cd8a63c018a1a9b0fef9136ad (patch)
tree015f9bd93dd782a75a018208d19d90aa1432065a /pkgs/development
parent9b847750a23865c4467ca90fcf46ab6795d88890 (diff)
parentba4cefe4ae70cfb9121281f508ed5d9fa9dbc662 (diff)
downloadnixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.tar
nixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.tar.gz
nixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.tar.bz2
nixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.tar.lz
nixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.tar.xz
nixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.tar.zst
nixlib-891c3721edd9881cd8a63c018a1a9b0fef9136ad.zip
Merge pull request #30234 from deedrah/aspell-data-dirs-from-nix-profiles
aspell: added new patch data-dirs-from-nix-profiles.patch
Diffstat (limited to 'pkgs/development')
-rw-r--r--pkgs/development/libraries/aspell/aspell-with-dicts.nix4
-rw-r--r--pkgs/development/libraries/aspell/data-dirs-from-nix-profiles.patch38
-rw-r--r--pkgs/development/libraries/aspell/default.nix27
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/;