2023-01-03 23:00:23 +00:00
|
|
|
{ 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
|
|
|
|
2020-05-15 14:20:36 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
2021-04-15 06:19:18 +00:00
|
|
|
# upstream unsets these to handle cross but it breaks our build
|
|
|
|
postPatch = ''
|
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace "GOOS= GOARCH= GOARM= GOFLAGS= CGO_ENABLED=" ""
|
|
|
|
'';
|
|
|
|
|
2020-05-15 14:20:36 +00:00
|
|
|
buildPhase = ''
|
2021-04-15 06:19:18 +00:00
|
|
|
runHook preBuild
|
|
|
|
make GO_LDFLAGS="-s -w" GH_VERSION=${version} bin/gh manpages
|
|
|
|
runHook postBuild
|
2020-05-15 14:20:36 +00:00
|
|
|
'';
|
2020-02-04 02:15:27 +00:00
|
|
|
|
2020-05-15 14:20:36 +00:00
|
|
|
installPhase = ''
|
2021-04-15 06:19:18 +00:00
|
|
|
runHook preInstall
|
2020-05-15 14:20:36 +00:00
|
|
|
install -Dm755 bin/gh -t $out/bin
|
|
|
|
installManPage share/man/*/*.[1-9]
|
2020-02-04 02:15:27 +00:00
|
|
|
|
2022-07-26 11:03:34 +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)
|
2021-04-15 06:19:18 +00:00
|
|
|
runHook postInstall
|
2020-02-04 02:15:27 +00:00
|
|
|
'';
|
|
|
|
|
2022-07-26 11:03:34 +00:00
|
|
|
# most tests require network access
|
2021-01-25 21:26:59 +00:00
|
|
|
doCheck = false;
|
2020-08-10 22:27:35 +00:00
|
|
|
|
2023-01-03 23:00:23 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = gh;
|
|
|
|
};
|
|
|
|
|
2020-03-28 23:32:01 +00:00
|
|
|
meta = with lib; {
|
2020-02-04 02:15:27 +00:00
|
|
|
description = "GitHub CLI tool";
|
2020-02-13 23:46:21 +00:00
|
|
|
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 ];
|
|
|
|
};
|
2020-05-15 14:20:36 +00:00
|
|
|
}
|