metal-cli: use versionCheckHook

This commit is contained in:
Pol Dellaiera 2025-05-03 19:47:02 +02:00
parent f783f655af
commit 21d9d56c17

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";
}; };
} })