2024-10-11 05:15:48 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
fetchFromGitHub,
|
|
|
|
buildGoModule,
|
|
|
|
installShellFiles,
|
|
|
|
stdenv,
|
|
|
|
testers,
|
|
|
|
gh,
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "gh";
|
2024-10-11 05:15:48 +00:00
|
|
|
version = "2.59.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "cli";
|
|
|
|
repo = "cli";
|
2024-10-11 05:15:48 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
hash = "sha256-QOc99KmcGk9b9uy1/y1FSe0zYE1q0g06k7niqtsMDmY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
vendorHash = "sha256-Mje0IbvRj6pmOe8s8PX87ntPE+ZZeciLyOP6fmv7PmI=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-05-29 06:06:01 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
2021-04-17 00:35:05 +00:00
|
|
|
runHook preBuild
|
2023-05-24 13:37:59 +00:00
|
|
|
make GO_LDFLAGS="-s -w" GH_VERSION=${version} bin/gh ${lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) "manpages"}
|
2021-04-17 00:35:05 +00:00
|
|
|
runHook postBuild
|
2020-05-29 06:06:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-10-11 05:15:48 +00:00
|
|
|
installPhase =
|
|
|
|
''
|
|
|
|
runHook preInstall
|
|
|
|
install -Dm755 bin/gh -t $out/bin
|
|
|
|
''
|
|
|
|
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
|
|
installManPage share/man/*/*.[1-9]
|
|
|
|
|
|
|
|
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-04-24 23:36:52 +00:00
|
|
|
|
2022-08-12 12:06:08 +00:00
|
|
|
# most tests require network access
|
2020-11-12 09:05:59 +00:00
|
|
|
doCheck = false;
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2023-01-11 07:51:40 +00:00
|
|
|
passthru.tests.version = testers.testVersion {
|
|
|
|
package = gh;
|
|
|
|
};
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "GitHub CLI tool";
|
|
|
|
homepage = "https://cli.github.com/";
|
2021-12-06 16:07:01 +00:00
|
|
|
changelog = "https://github.com/cli/cli/releases/tag/v${version}";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.mit;
|
2023-10-09 19:29:22 +00:00
|
|
|
mainProgram = "gh";
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ zowoq ];
|
|
|
|
};
|
2020-05-29 06:06:01 +00:00
|
|
|
}
|