ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / gk / gk-cli / package.nix
blob6ca98ca428632727a73e83a77bfc645928226b74
2   lib,
3   stdenv,
4   fetchzip,
5   coreutils,
6   installShellFiles,
7   makeWrapper,
8   writeShellScript,
9   curl,
10   jq,
11   common-updater-scripts,
14 stdenv.mkDerivation (finalAttrs: {
15   pname = "gk-cli";
16   version = "2.1.2";
18   src = (
19     finalAttrs.passthru.sources.${stdenv.system}
20       or (throw "gk-cli ${finalAttrs.version} unsupported system: ${stdenv.system}")
21   );
23   nativeBuildInputs = [
24     installShellFiles
25     makeWrapper
26   ];
28   installPhase = ''
29     runHook preInstall
31     install -Dm555 gk -t $out/bin/
33     installShellCompletion --bash ./**/gk.bash
34     installShellCompletion --fish ./**/gk.fish
35     installShellCompletion --zsh ./**/_gk
37     runHook postInstall
38   '';
40   postFixup = ''
41     wrapProgram $out/bin/gk \
42       --prefix PATH : "${lib.makeBinPath [ coreutils ]}"
43   '';
45   passthru = {
46     sources =
47       let
48         base_url = "https://github.com/gitkraken/gk-cli/releases/download/v${finalAttrs.version}/gk_${finalAttrs.version}_";
49       in
50       {
51         armv6l-linux = fetchzip {
52           url = "${base_url}Linux_arm6.zip";
53           hash = "sha256-pnEFTkx1JSmQlniVCXvIB6xGD8XyDh9OLDU0V9AZBTs=";
54           stripRoot = false;
55         };
56         armv7l-linux = fetchzip {
57           url = "${base_url}Linux_arm7.zip";
58           hash = "sha256-qj0++i698s4ELKHU9B2sGIqf9hUJip4+2Car+brkRkM=";
59           stripRoot = false;
60         };
61         aarch64-linux = fetchzip {
62           url = "${base_url}Linux_arm64.zip";
63           hash = "sha256-vHGhlRHbk2/s3YmBdOPDbalEydpQVFkHiCkBVywa4N0=";
64           stripRoot = false;
65         };
66         x86_32-linux = fetchzip {
67           url = "${base_url}Linux_i386.zip";
68           hash = "sha256-t+P9SpS9u/17kga74kbYjD6nkjiFusyIwCRGDnkP3tU=";
69           stripRoot = false;
70         };
71         x86_64-linux = fetchzip {
72           url = "${base_url}Linux_x86_64.zip";
73           hash = "sha256-O6T27edHi20ZFHiNaZKdk/5dtCn2Tpxm0PR934SRwFk=";
74           stripRoot = false;
75         };
76         aarch64-darwin = fetchzip {
77           url = "${base_url}macOS_arm64.zip";
78           hash = "sha256-LW2K+aveJiyYqfga2jpF3DvvFeHJuozqbc/afgtq2Oc=";
79           stripRoot = false;
80         };
81         x86_64-darwin = fetchzip {
82           url = "${base_url}macOS_x86_64.zip";
83           hash = "sha256-1w8B4YWouVViTGoUh987pPQIoqdzB0S+M2bBiRI6Kfg=";
84           stripRoot = false;
85         };
86         i686-windows = fetchzip {
87           url = "${base_url}Windows_i386.zip";
88           hash = "sha256-t81/wK1weZ/uEZ5TzivylARTUqks9rLIG7WzeoWXb1k=";
89           stripRoot = false;
90         };
91         x86_64-windows = fetchzip {
92           url = "${base_url}Windows_x86_64.zip";
93           hash = "sha256-9yydDMI9Gz/OswRhJHF+2c3Ia0zDmXMbf7byj6PJe24=";
94           stripRoot = false;
95         };
96       };
97     updateScript = writeShellScript "update-gk-cli" ''
98       set -o errexit
99       export PATH="${
100         lib.makeBinPath [
101           curl
102           jq
103           common-updater-scripts
104         ]
105       }"
106       NEW_VERSION=$(curl --silent https://api.github.com/repos/gitkraken/gk-cli/releases/latest | jq '.tag_name | ltrimstr("v")' --raw-output)
107       if [[ "${finalAttrs.version}" = "$NEW_VERSION" ]]; then
108           echo "The new version same as the old version."
109           exit 0
110       fi
111       for platform in ${lib.escapeShellArgs finalAttrs.meta.platforms}; do
112         update-source-version "gk-cli" "$NEW_VERSION" --ignore-same-version --source-key="passthru.sources.$platform"
113       done
114     '';
115   };
117   meta = {
118     description = "CLI for Git collaboration across multiple repos and services";
119     homepage = "https://www.gitkraken.com";
120     license = lib.licenses.unfree;
121     sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
122     maintainers = [ lib.maintainers.pinage404 ];
123     mainProgram = "gk";
124     platforms = builtins.attrNames finalAttrs.passthru.sources;
125   };