buildFishPlugin: allow finalAttrs pattern (#536604)

This commit is contained in:
Austin Horstman 2026-07-02 17:42:30 +00:00 committed by GitHub
commit 224e5773b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 66 additions and 79 deletions

View file

@ -3,84 +3,74 @@
lib,
writeScript,
wrapFish,
writableTmpDirAsHomeHook,
}:
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 = [
writableTmpDirAsHomeHook
(wrapFish {
pluginPkgs = checkPlugins;
functionDirs = checkFunctionDirs;
})
]
++ nativeCheckInputs;
checkPhase = ''
fish "${writeScript "${finalAttrs.name}-test" checkPhase}"
'';
};
}

View file

@ -5,15 +5,14 @@
fishtape,
jq,
}:
buildFishPlugin rec {
buildFishPlugin (finalAttrs: {
pname = "done";
version = "1.21.1";
src = fetchFromGitHub {
owner = "franciscolourenco";
repo = "done";
rev = version;
rev = finalAttrs.version;
hash = "sha256-GZ1ZpcaEfbcex6XvxOFJDJqoD9C5out0W4bkkn768r0=";
};
@ -37,4 +36,4 @@ buildFishPlugin rec {
rexies
];
};
}
})

View file

@ -3,15 +3,14 @@
buildFishPlugin,
fetchFromGitHub,
}:
buildFishPlugin rec {
buildFishPlugin (finalAttrs: {
pname = "pisces";
version = "0.7.0";
src = fetchFromGitHub {
owner = "laughedelic";
repo = "pisces";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-Oou2IeNNAqR00ZT3bss/DbhrJjGeMsn9dBBYhgdafBw=";
};
@ -21,4 +20,4 @@ buildFishPlugin rec {
license = lib.licenses.lgpl3;
maintainers = with lib.maintainers; [ vanilla ];
};
}
})

View file

@ -5,15 +5,14 @@
git,
fishtape_3,
}:
buildFishPlugin rec {
buildFishPlugin (finalAttrs: {
pname = "pure";
version = "4.15.0";
src = fetchFromGitHub {
owner = "pure-fish";
repo = "pure";
rev = "v${version}";
rev = "v${finalAttrs.version}";
hash = "sha256-fqcIfst9YnkOi50pIUMoJJQ7s1w1Vr6hRdEFo+FWIZY=";
};
@ -32,4 +31,4 @@ buildFishPlugin rec {
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ euxane ];
};
}
})