buildFishPlugin: allow finalAttrs pattern
This commit is contained in:
@@ -4,83 +4,72 @@
|
||||
writeScript,
|
||||
wrapFish,
|
||||
}:
|
||||
|
||||
attrs@{
|
||||
pname,
|
||||
version,
|
||||
src,
|
||||
|
||||
name ? "fishplugin-${pname}-${version}",
|
||||
unpackPhase ? "",
|
||||
configurePhase ? ":",
|
||||
buildPhase ? ":",
|
||||
preInstall ? "",
|
||||
postInstall ? "",
|
||||
|
||||
nativeCheckInputs ? [ ],
|
||||
# plugin packages to add to the vendor paths of the test fish shell
|
||||
checkPlugins ? [ ],
|
||||
# vendor directories to add to the function path of the test fish shell
|
||||
checkFunctionDirs ? [ ],
|
||||
# test script to be executed in a fish shell
|
||||
checkPhase ? "",
|
||||
doCheck ? checkPhase != "",
|
||||
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
# Do not pass attributes that are only relevant to buildFishPlugin to mkDerivation.
|
||||
drvAttrs = removeAttrs attrs [
|
||||
lib.extendMkDerivation {
|
||||
constructDrv = stdenv.mkDerivation;
|
||||
excludeDrvArgNames = [
|
||||
"checkPlugins"
|
||||
"checkFunctionDirs"
|
||||
];
|
||||
in
|
||||
extendDrvArgs =
|
||||
finalAttrs:
|
||||
{
|
||||
name ? "fishplugin-${finalAttrs.pname}-${finalAttrs.version}",
|
||||
unpackPhase ? "",
|
||||
configurePhase ? ":",
|
||||
buildPhase ? ":",
|
||||
|
||||
stdenv.mkDerivation (
|
||||
drvAttrs
|
||||
// {
|
||||
inherit name;
|
||||
inherit unpackPhase configurePhase buildPhase;
|
||||
nativeCheckInputs ? [ ],
|
||||
# plugin packages to add to the vendor paths of the test fish shell
|
||||
checkPlugins ? [ ],
|
||||
# vendor directories to add to the function path of the test fish shell
|
||||
checkFunctionDirs ? [ ],
|
||||
# test script to be executed in a fish shell
|
||||
checkPhase ? "",
|
||||
doCheck ? checkPhase != "",
|
||||
|
||||
inherit preInstall postInstall;
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
...
|
||||
}:
|
||||
{
|
||||
inherit name;
|
||||
inherit unpackPhase configurePhase buildPhase;
|
||||
|
||||
(
|
||||
install_vendor_files() {
|
||||
source="$1"
|
||||
target="$out/share/fish/vendor_$2.d"
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
# Check if any .fish file exists in $source
|
||||
[ -n "$(shopt -s nullglob; echo $source/*.fish)" ] || return 0
|
||||
(
|
||||
install_vendor_files() {
|
||||
source="$1"
|
||||
target="$out/share/fish/vendor_$2.d"
|
||||
|
||||
mkdir -p $target
|
||||
cp $source/*.fish "$target/"
|
||||
}
|
||||
# Check if any .fish file exists in $source
|
||||
[ -n "$(shopt -s nullglob; echo $source/*.fish)" ] || return 0
|
||||
|
||||
install_vendor_files completions completions
|
||||
install_vendor_files functions functions
|
||||
install_vendor_files conf conf
|
||||
install_vendor_files conf.d conf
|
||||
)
|
||||
mkdir -p $target
|
||||
cp $source/*.fish "$target/"
|
||||
}
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
install_vendor_files completions completions
|
||||
install_vendor_files functions functions
|
||||
install_vendor_files conf conf
|
||||
install_vendor_files conf.d conf
|
||||
)
|
||||
|
||||
inherit doCheck;
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
nativeCheckInputs = [
|
||||
(wrapFish {
|
||||
pluginPkgs = checkPlugins;
|
||||
functionDirs = checkFunctionDirs;
|
||||
})
|
||||
]
|
||||
++ nativeCheckInputs;
|
||||
inherit doCheck;
|
||||
|
||||
checkPhase = ''
|
||||
export HOME=$(mktemp -d) # fish wants a writable home
|
||||
fish "${writeScript "${name}-test" checkPhase}"
|
||||
'';
|
||||
}
|
||||
)
|
||||
nativeCheckInputs = [
|
||||
(wrapFish {
|
||||
pluginPkgs = checkPlugins;
|
||||
functionDirs = checkFunctionDirs;
|
||||
})
|
||||
]
|
||||
++ nativeCheckInputs;
|
||||
|
||||
checkPhase = ''
|
||||
export HOME=$(mktemp -d) # fish wants a writable home
|
||||
fish "${writeScript "${finalAttrs.name}-test" checkPhase}"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user