1{ lib
2, rustPlatform
3, fetchFromGitHub
4, cmake
5, pkg-config
6, stdenv
7, libiconv
8, Security
9, SystemConfiguration
10, curl
11, openssl
12, buildPackages
13, installShellFiles
14}:
15
16let
17 canRunCmd = stdenv.hostPlatform.emulatorAvailable buildPackages;
18 gix = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/gix";
19in rustPlatform.buildRustPackage rec {
20 pname = "gitoxide";
21 version = "0.35.0";
22
23 src = fetchFromGitHub {
24 owner = "Byron";
25 repo = "gitoxide";
26 rev = "v${version}";
27 hash = "sha256-Sl7nNYoiCdTZ50tIfJcq5x9KOBkgJsb5bq09chWbyQc=";
28 };
29
30 cargoHash = "sha256-G1NWRkhcmFrcHaIxQ7nzvRejPZUuZQDiNonZykkt4qM=";
31
32 nativeBuildInputs = [ cmake pkg-config installShellFiles ];
33
34 buildInputs = [ curl ] ++ (if stdenv.isDarwin
35 then [ libiconv Security SystemConfiguration ]
36 else [ openssl ]);
37
38 preFixup = lib.optionalString canRunCmd ''
39 installShellCompletion --cmd gix \
40 --bash <(${gix} completions --shell bash) \
41 --fish <(${gix} completions --shell fish) \
42 --zsh <(${gix} completions --shell zsh)
43 '';
44
45 # Needed to get openssl-sys to use pkg-config.
46 env.OPENSSL_NO_VENDOR = 1;
47
48 meta = with lib; {
49 description = "A command-line application for interacting with git repositories";
50 homepage = "https://github.com/Byron/gitoxide";
51 changelog = "https://github.com/Byron/gitoxide/blob/v${version}/CHANGELOG.md";
52 license = with licenses; [ mit /* or */ asl20 ];
53 maintainers = with maintainers; [ syberant ];
54 };
55}