about summary refs log tree commit diff
path: root/pkgs/applications/version-management
diff options
context:
space:
mode:
authorOTABI Tomoya <tomoya.otabi@gmail.com>2024-02-29 14:21:12 +0900
committerGitHub <noreply@github.com>2024-02-29 14:21:12 +0900
commite06ed3a7eb0e6fc64d92727a35f93b1b84a26f87 (patch)
tree33ee2d44cb9895610531ead232531c27e93effd8 /pkgs/applications/version-management
parente2376d8b73f5e1494e656a12cbaf9c21b8af1572 (diff)
parent9f94cdd5f6ad0db714b84095e28027588edfb3b8 (diff)
Merge pull request #289330 from sbatial/gix-completions
gitoxide: Install shell completions.
Diffstat (limited to 'pkgs/applications/version-management')
-rw-r--r--pkgs/applications/version-management/gitoxide/default.nix16
1 files changed, 14 insertions, 2 deletions
diff --git a/pkgs/applications/version-management/gitoxide/default.nix b/pkgs/applications/version-management/gitoxide/default.nix
index ed3f3c8764f4a..eb3ee122bf513 100644
--- a/pkgs/applications/version-management/gitoxide/default.nix
+++ b/pkgs/applications/version-management/gitoxide/default.nix
@@ -9,9 +9,14 @@
 , SystemConfiguration
 , curl
 , openssl
+, buildPackages
+, installShellFiles
 }:
 
-rustPlatform.buildRustPackage rec {
+let
+  canRunCmd = stdenv.hostPlatform.emulatorAvailable buildPackages;
+  gix = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/gix";
+in rustPlatform.buildRustPackage rec {
   pname = "gitoxide";
   version = "0.33.0";
 
@@ -24,12 +29,19 @@ rustPlatform.buildRustPackage rec {
 
   cargoHash = "sha256-JOl/hhyuc6vqeK6/oXXMB3fGRapBsuOTaUG+BQ9QSnk=";
 
-  nativeBuildInputs = [ cmake pkg-config ];
+  nativeBuildInputs = [ cmake pkg-config installShellFiles ];
 
   buildInputs = [ curl ] ++ (if stdenv.isDarwin
     then [ libiconv Security SystemConfiguration ]
     else [ openssl ]);
 
+  preFixup = lib.optionalString canRunCmd ''
+    installShellCompletion --cmd gix \
+      --bash <(${gix} completions --shell bash) \
+      --fish <(${gix} completions --shell fish) \
+      --zsh <(${gix} completions --shell zsh)
+  '';
+
   # Needed to get openssl-sys to use pkg-config.
   env.OPENSSL_NO_VENDOR = 1;