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 ])'
This commit is contained in:
parent
1d78df2729
commit
c0cf19608f
35
pkgs/development/libraries/aspell/aspell-with-dicts.nix
Normal file
35
pkgs/development/libraries/aspell/aspell-with-dicts.nix
Normal file
@ -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
|
||||
''
|
@ -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 { };
|
||||
|
Loading…
Reference in New Issue
Block a user