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

View File

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

View File

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

View File

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

View File

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

View File

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