nixpkgs/pkgs/applications/version-management/gh/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

57 lines
1.4 KiB
Nix
Raw Normal View History

{ lib, fetchFromGitHub, buildGoModule, installShellFiles, testers, gh }:
2020-02-04 02:15:27 +00:00
buildGoModule rec {
pname = "gh";
2023-02-08 05:35:50 +00:00
version = "2.23.0";
2020-02-04 02:15:27 +00:00
src = fetchFromGitHub {
owner = "cli";
repo = "cli";
rev = "v${version}";
2023-02-08 05:35:50 +00:00
hash = "sha256-91TmPIjFOCeZmbobn3mIJis5qofJFmNGuX19+Cyo8Ck=";
2020-02-04 02:15:27 +00:00
};
2023-02-08 05:35:50 +00:00
vendorHash = "sha256-NiXC0ooUkAqFCLp3eRBpryazQU94gSnw0gYFwQNeCo4=";
2020-02-04 02:15:27 +00:00
nativeBuildInputs = [ installShellFiles ];
# upstream unsets these to handle cross but it breaks our build
postPatch = ''
substituteInPlace Makefile \
--replace "GOOS= GOARCH= GOARM= GOFLAGS= CGO_ENABLED=" ""
'';
buildPhase = ''
runHook preBuild
make GO_LDFLAGS="-s -w" GH_VERSION=${version} bin/gh manpages
runHook postBuild
'';
2020-02-04 02:15:27 +00:00
installPhase = ''
runHook preInstall
install -Dm755 bin/gh -t $out/bin
installManPage share/man/*/*.[1-9]
2020-02-04 02:15:27 +00:00
installShellCompletion --cmd gh \
--bash <($out/bin/gh completion -s bash) \
--fish <($out/bin/gh completion -s fish) \
--zsh <($out/bin/gh completion -s zsh)
runHook postInstall
2020-02-04 02:15:27 +00:00
'';
# most tests require network access
doCheck = false;
2020-08-10 22:27:35 +00:00
passthru.tests.version = testers.testVersion {
package = gh;
};
meta = with lib; {
2020-02-04 02:15:27 +00:00
description = "GitHub CLI tool";
homepage = "https://cli.github.com/";
2021-12-02 20:21:38 +00:00
changelog = "https://github.com/cli/cli/releases/tag/v${version}";
2020-02-04 02:15:27 +00:00
license = licenses.mit;
maintainers = with maintainers; [ zowoq ];
};
}