modctl: use versionCheckHook and finalAttrs

Replace the manual installCheckPhase with versionCheckHook and
writableTmpDirAsHomeHook, matching the pattern used by other Go CLI
packages (e.g. nerdctl, temporal-cli).

This supersedes the aarch64-darwin workaround in cacd8e4dbb:
writableTmpDirAsHomeHook sets HOME to a writable directory, so modctl
no longer needs explicit --log-dir/--storage-dir flags to avoid the
os/user system calls that broke the install check on darwin.

Also switch rec -> finalAttrs, use tag instead of rev in
fetchFromGitHub, and drop the redundant -w ldflag (implied by -s).

Assisted-by: opencode (GLM-5.2)
This commit is contained in:
gbhu753
2026-06-30 01:11:46 +12:00
parent cacd8e4dbb
commit b5bf4ab550
+13 -12
View File
@@ -2,9 +2,11 @@
lib,
buildGoModule,
fetchFromGitHub,
versionCheckHook,
writableTmpDirAsHomeHook,
}:
buildGoModule rec {
buildGoModule (finalAttrs: {
__structuredAttrs = true;
pname = "modctl";
version = "0.2.2";
@@ -12,7 +14,7 @@ buildGoModule rec {
src = fetchFromGitHub {
owner = "modelpack";
repo = "modctl";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-A7s2jM+hR5WgeiWzPjjfS/AJy35x6kzewIucz713zLc=";
};
@@ -20,24 +22,23 @@ buildGoModule rec {
ldflags = [
"-s"
"-w"
"-X github.com/modelpack/modctl/pkg/version.GitVersion=v${version}"
"-X github.com/modelpack/modctl/pkg/version.GitVersion=v${finalAttrs.version}"
];
doInstallCheck = true;
installCheckPhase = ''
runHook preInstallCheck
$out/bin/modctl --help > /dev/null
$out/bin/modctl version --log-dir="$TMPDIR" --storage-dir="$TMPDIR" 2>&1 | grep -q "v${version}"
runHook postInstallCheck
'';
nativeInstallCheckInputs = [
writableTmpDirAsHomeHook
versionCheckHook
];
versionCheckProgramArg = "version";
versionCheckKeepEnvironment = [ "HOME" ];
meta = {
description = "CLI tool for managing OCI model artifacts based on Model Spec";
homepage = "https://github.com/modelpack/modctl";
changelog = "https://github.com/modelpack/modctl/releases/tag/v${version}";
changelog = "https://github.com/modelpack/modctl/releases/tag/v${finalAttrs.version}";
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ gbhu753 ];
mainProgram = "modctl";
};
}
})