1{
2 lib,
3 stdenv,
4 buildPackages,
5 fetchFromGitHub,
6 rustPlatform,
7 installShellFiles,
8 libiconv,
9 nix-update-script,
10 pkg-config,
11 openssl,
12}:
13let
14 canRunGitGr = stdenv.hostPlatform.emulatorAvailable buildPackages;
15 gitGr = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/git-gr";
16 pname = "git-gr";
17 version = "1.4.3";
18in
19rustPlatform.buildRustPackage {
20 inherit pname version;
21
22 src = fetchFromGitHub {
23 owner = "9999years";
24 repo = "git-gr";
25 tag = "v${version}";
26 hash = "sha256-t308Ep27iRvRHSdvVMOrRGVoajBtnTutHAkKbZkO7Wg=";
27 };
28
29 buildFeatures = [ "clap_mangen" ];
30
31 cargoHash = "sha256-5YHE1NVUcZ5NeOl3Z87l3PVsmlkswhnT83Oi9loJjdM=";
32
33 OPENSSL_NO_VENDOR = true;
34
35 nativeBuildInputs = [ installShellFiles ] ++ lib.optional stdenv.hostPlatform.isLinux pkg-config;
36
37 buildInputs =
38 lib.optional stdenv.hostPlatform.isLinux openssl
39 ++ lib.optionals stdenv.hostPlatform.isDarwin [
40 libiconv
41 ];
42
43 postInstall = lib.optionalString canRunGitGr ''
44 manpages=$(mktemp -d)
45 ${gitGr} manpages "$manpages"
46 for manpage in "$manpages"/*; do
47 installManPage "$manpage"
48 done
49
50 installShellCompletion --cmd git-gr \
51 --bash <(${gitGr} completions bash) \
52 --fish <(${gitGr} completions fish) \
53 --zsh <(${gitGr} completions zsh)
54 '';
55
56 meta = {
57 homepage = "https://github.com/9999years/git-gr";
58 changelog = "https://github.com/9999years/git-gr/releases/tag/v${version}";
59 description = "Gerrit CLI client";
60 license = [ lib.licenses.mit ];
61 maintainers = [ lib.maintainers._9999years ];
62 mainProgram = "git-gr";
63 };
64
65 passthru.updateScript = nix-update-script { };
66}