aspellWithDicts: use a single env

In c0cf19608faf447d4b78f77ff36a770462b19a22 the function
`aspellWithDicts` was introduced, that allows to build a derivation
consisting of aspell and specified dictionaries. In
96457d26dded05bcba8e9fbb9bf0255596654aab a fix was included to properly
find the dictionaries.

Issue #29429 describes that, while the current method works for the
aspell binary, it does not in case of the API.

This commit rewrites the wrapper into a single derivation, create a
single tree of symbolic references to both the binary and the
dictionaries so that its possible to find the dictionaries with the API.
Furthermore, the binary is wrapped so it can still find the dictionaries
as well.
This commit is contained in:
Frederik Rietdijk 2017-09-16 13:06:26 +02:00
parent 03fa6965ad
commit 91f7042aa0

View File

@ -4,8 +4,7 @@
{ aspell { aspell
, aspellDicts , aspellDicts
, makeWrapper , makeWrapper
, symlinkJoin , buildEnv
, runCommand
}: }:
f: f:
@ -14,22 +13,20 @@ let
# Dictionaries we want # Dictionaries we want
dicts = f aspellDicts; dicts = f aspellDicts;
# A tree containing the dictionaries in buildEnv {
dictEnv = symlinkJoin { name = "aspell-env";
name = "aspell-dicts";
paths = dicts;
};
in runCommand "aspell-env" {
buildInputs = [ makeWrapper ]; buildInputs = [ makeWrapper ];
} '' paths = [ aspell ] ++ dicts;
# Construct wrappers in /bin postBuild = ''
mkdir -p $out/bin # Construct wrappers in /bin
pushd "${aspell}/bin" unlink "$out/bin"
for prg in *; do mkdir -p "$out/bin"
if [ -f "$prg" ]; then pushd "${aspell}/bin"
makeWrapper "${aspell}/bin/$prg" "$out/bin/$prg" --set ASPELL_CONF "dict-dir ${dictEnv}/lib/aspell" for prg in *; do
fi if [ -f "$prg" ]; then
done makeWrapper "${aspell}/bin/$prg" "$out/bin/$prg" --set ASPELL_CONF "dict-dir $out/lib/aspell"
popd fi
'' done
popd
'';
}