depot/third_party/nixpkgs/pkgs/applications/version-management/git-and-tools/gh/default.nix
Default email be14b713bb Project import generated by Copybara.
GitOrigin-RevId: e5cc06a1e806070693add4f231060a62b962fc44
2021-04-17 02:35:05 +02:00

51 lines
1.2 KiB
Nix

{ lib, fetchFromGitHub, buildGoModule, installShellFiles }:
buildGoModule rec {
pname = "gh";
version = "1.9.1";
src = fetchFromGitHub {
owner = "cli";
repo = "cli";
rev = "v${version}";
sha256 = "1nrbz049nizrrfxdpws05gj0bqk47l4mrl4wcvfb6nwispc74ib0";
};
vendorSha256 = "0j2jy7n7hca5ybwwgh7cvm77j96ngaq1a1l5bl70vjpd8hz2qapc";
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
'';
installPhase = ''
runHook preInstall
install -Dm755 bin/gh -t $out/bin
installManPage share/man/*/*.[1-9]
for shell in bash fish zsh; do
$out/bin/gh completion -s $shell > gh.$shell
installShellCompletion gh.$shell
done
runHook postInstall
'';
# fails with `unable to find git executable in PATH`
doCheck = false;
meta = with lib; {
description = "GitHub CLI tool";
homepage = "https://cli.github.com/";
license = licenses.mit;
maintainers = with maintainers; [ zowoq ];
};
}