age: add a convenience function for wrapping with plugins

This commit is contained in:
Brian McGee
2025-04-01 16:10:25 +01:00
parent a18002797a
commit 5e4381c1c4
+39 -9
View File
@@ -3,16 +3,22 @@
buildGoModule,
fetchFromGitHub,
installShellFiles,
age-plugin-tpm,
age-plugin-ledger,
age-plugin-yubikey,
age-plugin-fido2-hmac,
makeWrapper,
runCommand,
}:
buildGoModule rec {
buildGoModule (final: {
pname = "age";
version = "1.2.1";
src = fetchFromGitHub {
owner = "FiloSottile";
repo = "age";
rev = "v${version}";
rev = "v${final.version}";
hash = "sha256-9ZJdrmqBj43zSvStt0r25wjSfnvitdx3GYtM3urHcaA=";
};
@@ -21,10 +27,12 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X main.Version=${version}"
"-X main.Version=${final.version}"
];
nativeBuildInputs = [ installShellFiles ];
nativeBuildInputs = [
installShellFiles
];
preInstall = ''
installManPage doc/*.1
@@ -32,10 +40,10 @@ buildGoModule rec {
doInstallCheck = true;
installCheckPhase = ''
if [[ "$("$out/bin/${pname}" --version)" == "${version}" ]]; then
echo '${pname} smoke check passed'
if [[ "$("$out/bin/${final.pname}" --version)" == "${final.version}" ]]; then
echo '${final.pname} smoke check passed'
else
echo '${pname} smoke check failed'
echo '${final.pname} smoke check failed'
return 1
fi
'';
@@ -46,12 +54,34 @@ buildGoModule rec {
"TestScript/plugin"
];
# group age plugins together
passthru.plugins = {
inherit
age-plugin-tpm
age-plugin-ledger
age-plugin-yubikey
age-plugin-fido2-hmac
;
};
# convenience function for wrapping sops with plugins
passthru.withPlugins =
filter:
runCommand "age-${final.version}-with-plugins"
{
nativeBuildInputs = [ makeWrapper ];
}
''
makeWrapper ${lib.getBin final.finalPackage}/bin/age $out/bin/age \
--prefix PATH : "${lib.makeBinPath (filter final.passthru.plugins)}"
'';
meta = with lib; {
changelog = "https://github.com/FiloSottile/age/releases/tag/v${version}";
changelog = "https://github.com/FiloSottile/age/releases/tag/v${final.version}";
homepage = "https://age-encryption.org/";
description = "Modern encryption tool with small explicit keys";
license = licenses.bsd3;
mainProgram = "age";
maintainers = with maintainers; [ tazjin ];
};
}
})