nixpkgs-suyu/pkgs/applications/version-management/git-and-tools/gh/default.nix

52 lines
1.2 KiB
Nix
Raw Normal View History

{ lib, fetchFromGitHub, buildGoModule, installShellFiles }:
2020-02-04 03:15:27 +01:00
buildGoModule rec {
pname = "gh";
2021-10-27 12:13:30 +02:00
version = "2.2.0";
2020-02-04 03:15:27 +01:00
src = fetchFromGitHub {
owner = "cli";
repo = "cli";
rev = "v${version}";
2021-10-27 12:13:30 +02:00
sha256 = "sha256-/czexUqpdsFQAteZ75ur2SFibrtZWffHpPBEPlLQXSY=";
2020-02-04 03:15:27 +01:00
};
2021-10-27 12:13:30 +02:00
vendorSha256 = "sha256-slMl5dCyyVNBgDbpYECfYUbpJJ7sWuSGSutYR3rTzj0=";
2020-02-04 03:15:27 +01: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 03:15:27 +01:00
installPhase = ''
runHook preInstall
install -Dm755 bin/gh -t $out/bin
installManPage share/man/*/*.[1-9]
2020-02-04 03:15:27 +01:00
for shell in bash fish zsh; do
$out/bin/gh completion -s $shell > gh.$shell
installShellCompletion gh.$shell
done
runHook postInstall
2020-02-04 03:15:27 +01:00
'';
# fails with `unable to find git executable in PATH`
doCheck = false;
2020-08-11 00:27:35 +02:00
meta = with lib; {
2020-02-04 03:15:27 +01:00
description = "GitHub CLI tool";
homepage = "https://cli.github.com/";
2020-02-04 03:15:27 +01:00
license = licenses.mit;
maintainers = with maintainers; [ zowoq ];
};
}