summary refs log tree commit diff
path: root/pkgs/development/libraries/aspell/data-dirs-from-nix-profiles.patch
blob: c19827ba93e4b305435e50ceb7e61d64d064381d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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)