Skip to content

Commit c0cf196

Browse files
committedJul 17, 2017
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 ])'
1 parent 1d78df2 commit c0cf196

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Create a derivation that contains aspell and selected dictionaries.
2+
# Composition is done using `pkgs.buildEnv`.
3+
4+
{ aspell
5+
, aspellDicts
6+
, makeWrapper
7+
, symlinkJoin
8+
, runCommand
9+
}:
10+
11+
f:
12+
13+
let
14+
# Dictionaries we want
15+
dicts = f aspellDicts;
16+
17+
# A tree containing the dictionaries
18+
dictEnv = symlinkJoin {
19+
name = "aspell-dicts";
20+
paths = dicts;
21+
};
22+
23+
in runCommand "aspell-env" {
24+
buildInputs = [ makeWrapper ];
25+
} ''
26+
# Construct wrappers in /bin
27+
mkdir -p $out/bin
28+
pushd "${aspell}/bin"
29+
for prg in *; do
30+
if [ -f "$prg" ]; then
31+
makeWrapper "${aspell}/bin/$prg" "$out/bin/$prg" --set ASPELL_CONF "data-dir ${dictEnv}/lib/aspell"
32+
fi
33+
done
34+
popd
35+
''

‎pkgs/top-level/all-packages.nix

+2
Original file line numberDiff line numberDiff line change
@@ -7393,6 +7393,8 @@ with pkgs;
73937393

73947394
aspellDicts = recurseIntoAttrs (callPackages ../development/libraries/aspell/dictionaries.nix {});
73957395

7396+
aspellWithDicts = callPackage ../development/libraries/aspell/aspell-with-dicts.nix { };
7397+
73967398
attica = callPackage ../development/libraries/attica { };
73977399

73987400
attr = callPackage ../development/libraries/attr { };

0 commit comments

Comments
 (0)
Please sign in to comment.