2021-01-15 22:18:51 +00:00
|
|
|
{ stdenv, lib, writeScript, wrapFish }:
|
2021-01-05 17:05:55 +00:00
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
attrs@{
|
2021-01-05 17:05:55 +00:00
|
|
|
pname,
|
|
|
|
version,
|
|
|
|
src,
|
|
|
|
|
|
|
|
name ? "fishplugin-${pname}-${version}",
|
|
|
|
unpackPhase ? "",
|
|
|
|
configurePhase ? ":",
|
|
|
|
buildPhase ? ":",
|
|
|
|
preInstall ? "",
|
|
|
|
postInstall ? "",
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs ? [],
|
2021-01-15 22:18:51 +00:00
|
|
|
# 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 ? [],
|
2021-01-05 17:05:55 +00:00
|
|
|
# test script to be executed in a fish shell
|
|
|
|
checkPhase ? "",
|
|
|
|
doCheck ? checkPhase != "",
|
|
|
|
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
|
2021-03-19 17:17:44 +00:00
|
|
|
let
|
|
|
|
# Do not pass attributes that are only relevant to buildFishPlugin to mkDerivation.
|
|
|
|
drvAttrs = builtins.removeAttrs attrs [
|
|
|
|
"checkPlugins"
|
|
|
|
"checkFunctionDirs"
|
|
|
|
];
|
|
|
|
in
|
|
|
|
|
|
|
|
stdenv.mkDerivation (drvAttrs // {
|
2021-01-05 17:05:55 +00:00
|
|
|
inherit name;
|
|
|
|
inherit unpackPhase configurePhase buildPhase;
|
|
|
|
|
|
|
|
inherit preInstall postInstall;
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
(
|
|
|
|
install_vendor_files() {
|
|
|
|
source="$1"
|
2021-01-15 22:18:51 +00:00
|
|
|
target="$out/share/fish/vendor_$2.d"
|
2021-01-05 17:05:55 +00:00
|
|
|
|
|
|
|
[ -d $source ] || return 0
|
|
|
|
mkdir -p $target
|
|
|
|
cp -r $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;
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
nativeCheckInputs = [ (wrapFish {
|
2021-01-15 22:18:51 +00:00
|
|
|
pluginPkgs = checkPlugins;
|
|
|
|
functionDirs = checkFunctionDirs;
|
2023-02-02 18:25:31 +00:00
|
|
|
}) ] ++ nativeCheckInputs;
|
2021-01-15 22:18:51 +00:00
|
|
|
|
2021-01-05 17:05:55 +00:00
|
|
|
checkPhase = ''
|
|
|
|
export HOME=$(mktemp -d) # fish wants a writable home
|
|
|
|
fish "${writeScript "${name}-test" checkPhase}"
|
|
|
|
'';
|
|
|
|
})
|