77 lines
1.8 KiB
Nix
77 lines
1.8 KiB
Nix
{
|
|
stdenv,
|
|
lib,
|
|
writeScript,
|
|
wrapFish,
|
|
writableTmpDirAsHomeHook,
|
|
}:
|
|
lib.extendMkDerivation {
|
|
constructDrv = stdenv.mkDerivation;
|
|
excludeDrvArgNames = [
|
|
"checkPlugins"
|
|
"checkFunctionDirs"
|
|
];
|
|
extendDrvArgs =
|
|
finalAttrs:
|
|
{
|
|
name ? "fishplugin-${finalAttrs.pname}-${finalAttrs.version}",
|
|
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 name;
|
|
inherit unpackPhase configurePhase buildPhase;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
(
|
|
install_vendor_files() {
|
|
source="$1"
|
|
target="$out/share/fish/vendor_$2.d"
|
|
|
|
# Check if any .fish file exists in $source
|
|
[ -n "$(shopt -s nullglob; echo $source/*.fish)" ] || return 0
|
|
|
|
mkdir -p $target
|
|
cp $source/*.fish "$target/"
|
|
}
|
|
|
|
install_vendor_files completions completions
|
|
install_vendor_files functions functions
|
|
install_vendor_files conf conf
|
|
install_vendor_files conf.d conf
|
|
)
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
inherit doCheck;
|
|
|
|
nativeCheckInputs = [
|
|
writableTmpDirAsHomeHook
|
|
(wrapFish {
|
|
pluginPkgs = checkPlugins;
|
|
functionDirs = checkFunctionDirs;
|
|
})
|
|
]
|
|
++ nativeCheckInputs;
|
|
|
|
checkPhase = ''
|
|
fish "${writeScript "${finalAttrs.name}-test" checkPhase}"
|
|
'';
|
|
};
|
|
}
|