lol
1{ lib, fetchFromGitHub, buildGoModule, installShellFiles, stdenv, testers, gh }:
2
3buildGoModule rec {
4 pname = "gh";
5 version = "2.39.1";
6
7 src = fetchFromGitHub {
8 owner = "cli";
9 repo = "cli";
10 rev = "v${version}";
11 hash = "sha256-OvelaxyQNeh6h7wn4Z/vRicufOoxrTdmnWl9hKW00jU=";
12 };
13
14 vendorHash = "sha256-RFForZy/MktbrNrcpp9G6VCB7A98liJvCxS0Yb16sMc=";
15
16 nativeBuildInputs = [ installShellFiles ];
17
18 buildPhase = ''
19 runHook preBuild
20 make GO_LDFLAGS="-s -w" GH_VERSION=${version} bin/gh ${lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) "manpages"}
21 runHook postBuild
22 '';
23
24 installPhase = ''
25 runHook preInstall
26 install -Dm755 bin/gh -t $out/bin
27 '' + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
28 installManPage share/man/*/*.[1-9]
29
30 installShellCompletion --cmd gh \
31 --bash <($out/bin/gh completion -s bash) \
32 --fish <($out/bin/gh completion -s fish) \
33 --zsh <($out/bin/gh completion -s zsh)
34 '' + ''
35 runHook postInstall
36 '';
37
38 # most tests require network access
39 doCheck = false;
40
41 passthru.tests.version = testers.testVersion {
42 package = gh;
43 };
44
45 meta = with lib; {
46 description = "GitHub CLI tool";
47 homepage = "https://cli.github.com/";
48 changelog = "https://github.com/cli/cli/releases/tag/v${version}";
49 license = licenses.mit;
50 mainProgram = "gh";
51 maintainers = with maintainers; [ zowoq ];
52 };
53}