depot/third_party/nixpkgs/pkgs/applications/version-management/git-and-tools/gh/default.nix
Default email 893b09d324 Project import generated by Copybara.
GitOrigin-RevId: eac07edbd20ed4908b98790ba299250b5527ecdf
2021-12-24 12:21:11 +08:00

52 lines
1.3 KiB
Nix

{ lib, fetchFromGitHub, buildGoModule, installShellFiles }:
buildGoModule rec {
pname = "gh";
version = "2.4.0";
src = fetchFromGitHub {
owner = "cli";
repo = "cli";
rev = "v${version}";
sha256 = "sha256-RFKS6fHh+rX5S31MvAQpJUNgaI6loiUw0FNkdsMFqlQ=";
};
vendorSha256 = "sha256-6owFzn+NAhlHjTJEur1H5oZY87ZoptvAnF2w6kafix8=";
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/";
changelog = "https://github.com/cli/cli/releases/tag/v${version}";
license = licenses.mit;
maintainers = with maintainers; [ zowoq ];
};
}