summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederik Rietdijk <fridh@fridh.nl>2017-06-16 15:52:46 +0200
committerFrederik Rietdijk <fridh@fridh.nl>2017-07-17 10:17:20 +0200
commitc0cf19608faf447d4b78f77ff36a770462b19a22 (patch)
tree8866975a989f58a4defcad35d6031c9ffd6819df
parent1d78df27294017d464e60bf9b0595e7e42cfca55 (diff)
downloadnixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.tar
nixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.tar.gz
nixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.tar.bz2
nixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.tar.lz
nixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.tar.xz
nixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.tar.zst
nixlib-c0cf19608faf447d4b78f77ff36a770462b19a22.zip
aspellWithDicts: create derivation with aspell and selected dictionaries
Currently, `aspell` checks the active profiles for dictionaries. While
this may be convenient, it does not work with `nix-shell` and it doesn't
allow any isolation.

This commit adds the possibility to use composition by creating a
derivation with `symlinkJoin` that contains all the chosen dictionaries,
and another derivation that wraps the executables linking to the dictionaries.

Nix example:

my_aspell = aspellWithDicts(ps: with ps; [ en nl ])

`nix-shell` example:

nix-shell -p 'aspellWithDicts(ps: with ps; [ en nl ])'
-rw-r--r--pkgs/development/libraries/aspell/aspell-with-dicts.nix35
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 37 insertions, 0 deletions
diff --git a/pkgs/development/libraries/aspell/aspell-with-dicts.nix b/pkgs/development/libraries/aspell/aspell-with-dicts.nix
new file mode 100644
index 000000000000..eb96070f4fd7
--- /dev/null
+++ b/pkgs/development/libraries/aspell/aspell-with-dicts.nix
@@ -0,0 +1,35 @@
+# Create a derivation that contains aspell and selected dictionaries.
+# Composition is done using `pkgs.buildEnv`.
+
+{ aspell
+, aspellDicts
+, makeWrapper
+, symlinkJoin
+, runCommand
+}:
+
+f:
+
+let
+  # Dictionaries we want
+  dicts = f aspellDicts;
+
+  # A tree containing the dictionaries
+  dictEnv = symlinkJoin {
+    name = "aspell-dicts";
+    paths = dicts;
+  };
+
+in runCommand "aspell-env" {
+  buildInputs = [ makeWrapper ];
+} ''
+  # Construct wrappers in /bin
+  mkdir -p $out/bin
+  pushd "${aspell}/bin"
+  for prg in *; do
+    if [ -f "$prg" ]; then
+      makeWrapper "${aspell}/bin/$prg" "$out/bin/$prg" --set ASPELL_CONF "data-dir ${dictEnv}/lib/aspell"
+    fi
+  done
+  popd
+''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 3d09b8893b43..149f99504a74 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -7393,6 +7393,8 @@ with pkgs;
 
   aspellDicts = recurseIntoAttrs (callPackages ../development/libraries/aspell/dictionaries.nix {});
 
+  aspellWithDicts = callPackage ../development/libraries/aspell/aspell-with-dicts.nix { };
+
   attica = callPackage ../development/libraries/attica { };
 
   attr = callPackage ../development/libraries/attr { };