From b5bf4ab5500d97ac2ebe34a546a5755f825e6805 Mon Sep 17 00:00:00 2001 From: gbhu753 Date: Tue, 30 Jun 2026 01:11:46 +1200 Subject: [PATCH] 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 cacd8e4dbbc3: 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) --- pkgs/by-name/mo/modctl/package.nix | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/pkgs/by-name/mo/modctl/package.nix b/pkgs/by-name/mo/modctl/package.nix index bb82464ff705..eb149689558f 100644 --- a/pkgs/by-name/mo/modctl/package.nix +++ b/pkgs/by-name/mo/modctl/package.nix @@ -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"; }; -} +})