diff --git a/pkgs/by-name/mo/modctl/package.nix b/pkgs/by-name/mo/modctl/package.nix index eb149689558f..c910dd3112ad 100644 --- a/pkgs/by-name/mo/modctl/package.nix +++ b/pkgs/by-name/mo/modctl/package.nix @@ -3,7 +3,6 @@ buildGoModule, fetchFromGitHub, versionCheckHook, - writableTmpDirAsHomeHook, }: buildGoModule (finalAttrs: { @@ -26,12 +25,25 @@ buildGoModule (finalAttrs: { ]; doInstallCheck = true; - nativeInstallCheckInputs = [ - writableTmpDirAsHomeHook - versionCheckHook - ]; + nativeInstallCheckInputs = [ versionCheckHook ]; versionCheckProgramArg = "version"; - versionCheckKeepEnvironment = [ "HOME" ]; + + # modctl's cobra commands invoke config.NewRoot(), which uses + # os/user.Current() to find the home directory. On darwin os/user + # bypasses $HOME and resolves it via getpwuid (returning /var/empty, + # not writable), so the install check fails. versionCheckHook only + # accepts a single argument, so wrap the binary and point + # --log-dir/--storage-dir at TMPDIR to keep the check working on all + # platforms. + preVersionCheck = '' + wrapper="$NIX_BUILD_TOP/modctl-version-check" + cat > "$wrapper" <