diff --git a/pkgs/by-name/gl/glab/package.nix b/pkgs/by-name/gl/glab/package.nix index dc99f424e6d7c..960ca9c5b5fd0 100644 --- a/pkgs/by-name/gl/glab/package.nix +++ b/pkgs/by-name/gl/glab/package.nix @@ -3,23 +3,32 @@ buildGoModule, fetchFromGitLab, installShellFiles, + makeBinaryWrapper, stdenv, nix-update-script, writableTmpDirAsHomeHook, + versionCheckHook, + gitMinimal, }: buildGoModule (finalAttrs: { pname = "glab"; - version = "1.61.0"; + version = "1.62.0"; src = fetchFromGitLab { owner = "gitlab-org"; repo = "cli"; tag = "v${finalAttrs.version}"; - hash = "sha256-pouFnmHCfRFDy+MMbRI82o73jO8hRewHeXgGnJ4hnww="; + hash = "sha256-+dXMlNc54i/vEwYV0YRKXrdWejcgfXFW+tFq3tf8TZY="; + leaveDotGit = true; + postFetch = '' + cd "$out" + git rev-parse --short HEAD > $out/COMMIT + find "$out" -name .git -print0 | xargs -0 rm -rf + ''; }; - vendorHash = "sha256-COp4RebkU36OChbZFeLALUppXqHLRbrm3D64Hb5RmI4="; + vendorHash = "sha256-sgph04zjHvvgL0QJm2//h8jyDg/5NY7dq50C0G0hYYM="; ldflags = [ "-s" @@ -27,11 +36,16 @@ buildGoModule (finalAttrs: { "-X main.version=${finalAttrs.version}" ]; - nativeCheckInputs = [ writableTmpDirAsHomeHook ]; + preBuild = '' + ldflags+=" -X main.commit=$(cat COMMIT)" + ''; - subPackages = [ "cmd/glab" ]; + nativeBuildInputs = [ + installShellFiles + makeBinaryWrapper + ]; - nativeBuildInputs = [ installShellFiles ]; + subPackages = [ "cmd/glab" ]; postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' make manpage @@ -40,8 +54,27 @@ buildGoModule (finalAttrs: { --bash <($out/bin/glab completion -s bash) \ --fish <($out/bin/glab completion -s fish) \ --zsh <($out/bin/glab completion -s zsh) + + wrapProgram $out/bin/glab \ + --set-default GLAB_CHECK_UPDATE 0 \ + --set-default GLAB_SEND_TELEMETRY 0 ''; + nativeCheckInputs = [ writableTmpDirAsHomeHook ]; + + preCheck = '' + git init + ''; + + doInstallCheck = true; + nativeInstallCheckInputs = [ + gitMinimal + versionCheckHook + writableTmpDirAsHomeHook + ]; + versionCheckProgramArg = "version"; + versionCheckKeepEnvironment = [ "HOME" ]; + passthru.updateScript = nix-update-script { }; meta = {