treewide: use versionCheckHook (#404005)

This commit is contained in:
Pol Dellaiera 2025-05-04 11:37:46 +02:00 committed by GitHub
commit 6840a89478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 77 additions and 83 deletions

View File

@ -2,20 +2,22 @@
lib,
buildGoModule,
fetchFromGitHub,
versionCheckHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "atlantis";
version = "0.34.0";
src = fetchFromGitHub {
owner = "runatlantis";
repo = "atlantis";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-2xgU3H6X9EcbySV9RXN5oCn+7EkfdwebeYsL5+Vl69E=";
};
ldflags = [
"-X=main.version=${version}"
"-X=main.version=${finalAttrs.version}"
"-X=main.date=1970-01-01T00:00:00Z"
];
@ -24,15 +26,15 @@ buildGoModule rec {
subPackages = [ "." ];
doInstallCheck = true;
installCheckPhase = ''
$out/bin/atlantis version | grep ${version} > /dev/null
'';
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgram = "${placeholder "out"}/bin/atlantis";
versionCheckProgramArg = "version";
meta = with lib; {
meta = {
homepage = "https://github.com/runatlantis/atlantis";
description = "Terraform Pull Request Automation";
mainProgram = "atlantis";
license = licenses.asl20;
maintainers = with maintainers; [ jpotier ];
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ jpotier ];
};
}
})

View File

@ -4,23 +4,24 @@
rustPlatform,
fetchFromGitHub,
installShellFiles,
makeWrapper,
makeBinaryWrapper,
pkg-config,
libgit2,
zlib,
buildPackages,
versionCheckHook,
withClipboard ? true,
withTrash ? !stdenv.hostPlatform.isDarwin,
}:
rustPlatform.buildRustPackage rec {
rustPlatform.buildRustPackage (finalAttrs: {
pname = "broot";
version = "1.46.3";
src = fetchFromGitHub {
owner = "Canop";
repo = "broot";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-MfBlJ7SokBKkAkmBSj4NsE2hKVqYeGN3z/xiq2VK3vU=";
};
@ -29,7 +30,7 @@ rustPlatform.buildRustPackage rec {
nativeBuildInputs = [
installShellFiles
makeWrapper
makeBinaryWrapper
pkg-config
];
@ -43,13 +44,13 @@ rustPlatform.buildRustPackage rec {
buildFeatures = lib.optionals withTrash [ "trash" ] ++ lib.optionals withClipboard [ "clipboard" ];
RUSTONIG_SYSTEM_LIBONIG = true;
env.RUSTONIG_SYSTEM_LIBONIG = true;
postPatch = ''
# Fill the version stub in the man page. We can't fill the date
# stub reproducibly.
substitute man/page man/broot.1 \
--replace "#version" "${version}"
--replace-fail "#version" "${finalAttrs.version}"
'';
postInstall =
@ -84,16 +85,15 @@ rustPlatform.buildRustPackage rec {
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/broot --version | grep "${version}"
'';
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
meta = with lib; {
description = "Interactive tree view, a fuzzy search, a balanced BFS descent and customizable commands";
homepage = "https://dystroy.org/broot/";
changelog = "https://github.com/Canop/broot/releases/tag/v${version}";
changelog = "https://github.com/Canop/broot/releases/tag/v${finalAttrs.version}";
maintainers = with maintainers; [ dywedir ];
license = with licenses; [ mit ];
mainProgram = "broot";
};
}
})

View File

@ -3,16 +3,18 @@
buildGoModule,
fetchFromGitHub,
installShellFiles,
versionCheckHook,
writableTmpDirAsHomeHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "conftest";
version = "0.59.0";
src = fetchFromGitHub {
owner = "open-policy-agent";
repo = "conftest";
tag = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-bmZp1cPNTm6m30YxjlWdnfv2437nDXH+taDNFZ0OKIY=";
};
vendorHash = "sha256-aPvGbtAucb9OdcydO4dMLJrrM3XretPI7zyJULlm1fg=";
@ -20,17 +22,13 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X github.com/open-policy-agent/conftest/internal/commands.version=${version}"
"-X github.com/open-policy-agent/conftest/internal/commands.version=${finalAttrs.version}"
];
nativeBuildInputs = [
installShellFiles
];
preCheck = ''
export HOME="$(mktemp -d)"
'';
postInstall = ''
installShellCompletion --cmd conftest \
--bash <($out/bin/conftest completion bash) \
@ -38,19 +36,23 @@ buildGoModule rec {
--zsh <($out/bin/conftest completion zsh)
'';
doInstallCheck = true;
installCheckPhase = ''
export HOME="$(mktemp -d)"
$out/bin/conftest --version | grep ${version} > /dev/null
'';
nativeCheckInputs = [
writableTmpDirAsHomeHook
];
meta = with lib; {
doInstallCheck = true;
nativeInstallCheckInputs = [
versionCheckHook
];
versionCheckProgramArg = "--version";
meta = {
description = "Write tests against structured configuration data";
mainProgram = "conftest";
downloadPage = "https://github.com/open-policy-agent/conftest";
homepage = "https://www.conftest.dev";
changelog = "https://github.com/open-policy-agent/conftest/releases/tag/v${version}";
license = licenses.asl20;
changelog = "https://github.com/open-policy-agent/conftest/releases/tag/v${finalAttrs.version}";
license = lib.licenses.asl20;
longDescription = ''
Conftest helps you write tests against structured configuration data.
Using Conftest you can write tests for your Kubernetes configuration,
@ -61,9 +63,9 @@ buildGoModule rec {
assertions. You can read more about Rego in 'How do I write policies' in
the Open Policy Agent documentation.
'';
maintainers = with maintainers; [
maintainers = with lib.maintainers; [
jk
yurrriq
];
};
}
})

View File

@ -3,21 +3,22 @@
buildGoModule,
fetchFromGitHub,
nixosTests,
versionCheckHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "ferretdb";
version = "1.24.0";
src = fetchFromGitHub {
owner = "FerretDB";
repo = "FerretDB";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-WMejspnk2PvJhvNGi4h+DF+fzipuOMcS1QWim5DnAhQ=";
};
postPatch = ''
echo v${version} > build/version/version.txt
echo v${finalAttrs.version} > build/version/version.txt
echo nixpkgs > build/version/package.txt
'';
@ -32,22 +33,21 @@ buildGoModule rec {
# the binary panics if something required wasn't set during compilation
doInstallCheck = true;
installCheckPhase = ''
$out/bin/ferretdb --version | grep ${version}
'';
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "--version";
passthru.tests = nixosTests.ferretdb;
meta = with lib; {
meta = {
description = "Truly Open Source MongoDB alternative";
mainProgram = "ferretdb";
changelog = "https://github.com/FerretDB/FerretDB/releases/tag/v${version}";
changelog = "https://github.com/FerretDB/FerretDB/releases/tag/v${finalAttrs.version}";
homepage = "https://www.ferretdb.com/";
license = licenses.asl20;
maintainers = with maintainers; [
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
dit7ya
noisersup
julienmalka
];
};
}
})

View File

@ -3,16 +3,17 @@
buildGoModule,
fetchFromGitHub,
installShellFiles,
versionCheckHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "metal-cli";
version = "0.25.0";
src = fetchFromGitHub {
owner = "equinix";
repo = pname;
rev = "v${version}";
repo = "metal-cli";
tag = "v${finalAttrs.version}";
hash = "sha256-+hpsGFZHuVhh+fKVcap0vhoUmRs3xPgUwW8SD56m6uI=";
};
@ -21,7 +22,7 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X github.com/equinix/metal-cli/cmd.Version=${version}"
"-X github.com/equinix/metal-cli/cmd.Version=${finalAttrs.version}"
];
nativeBuildInputs = [
@ -38,21 +39,20 @@ buildGoModule rec {
doCheck = false;
doInstallCheck = true;
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgram = "${placeholder "out"}/bin/metal";
versionCheckProgramArg = "--version";
installCheckPhase = ''
$out/bin/metal --version | grep ${version}
'';
meta = with lib; {
meta = {
description = "Official Equinix Metal CLI";
homepage = "https://github.com/equinix/metal-cli/";
changelog = "https://github.com/equinix/metal-cli/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [
changelog = "https://github.com/equinix/metal-cli/releases/tag/v${finalAttrs.version}";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
Br1ght0ne
nshalman
teutat3s
];
mainProgram = "metal";
};
}
})

View File

@ -5,16 +5,17 @@
installShellFiles,
testers,
oras,
versionCheckHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
pname = "oras";
version = "1.2.3";
src = fetchFromGitHub {
owner = "oras-project";
repo = "oras";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-IXIw2prApg5iL3BPbOY4x09KjyhFvKofgfz2L6UXKR8=";
};
@ -27,7 +28,7 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X oras.land/oras/internal/version.Version=${version}"
"-X oras.land/oras/internal/version.Version=${finalAttrs.version}"
"-X oras.land/oras/internal/version.BuildMetadata="
"-X oras.land/oras/internal/version.GitTreeState=clean"
];
@ -40,29 +41,18 @@ buildGoModule rec {
'';
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
nativeInstallCheckInputs = [ versionCheckHook ];
versionCheckProgramArg = "version";
$out/bin/oras --help
$out/bin/oras version | grep "${version}"
runHook postInstallCheck
'';
passthru.tests.version = testers.testVersion {
package = oras;
command = "oras version";
};
meta = with lib; {
meta = {
homepage = "https://oras.land/";
changelog = "https://github.com/oras-project/oras/releases/tag/v${version}";
changelog = "https://github.com/oras-project/oras/releases/tag/v${finalAttrs.version}";
description = "ORAS project provides a way to push and pull OCI Artifacts to and from OCI Registries";
mainProgram = "oras";
license = licenses.asl20;
maintainers = with maintainers; [
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [
jk
developer-guy
];
};
}
})