about summary refs log tree commit diff
path: root/pkgs/tools/misc/vrc-get/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/misc/vrc-get/default.nix')
-rw-r--r--pkgs/tools/misc/vrc-get/default.nix23
1 files changed, 18 insertions, 5 deletions
diff --git a/pkgs/tools/misc/vrc-get/default.nix b/pkgs/tools/misc/vrc-get/default.nix
index 140fba5c11f30..dac2f34dbacae 100644
--- a/pkgs/tools/misc/vrc-get/default.nix
+++ b/pkgs/tools/misc/vrc-get/default.nix
@@ -1,19 +1,32 @@
-{ fetchCrate, lib, rustPlatform, pkg-config, stdenv, Security, SystemConfiguration }:
+{ fetchCrate, installShellFiles, lib, rustPlatform, pkg-config, stdenv, Security, SystemConfiguration, buildPackages }:
 
 rustPlatform.buildRustPackage rec {
   pname = "vrc-get";
-  version = "1.8.0";
+  version = "1.8.1";
 
   src = fetchCrate {
     inherit pname version;
-    hash = "sha256-+xbHw1DpFmapjsFoUvxUqTok8TKMebMw3gYjO/rx/iU=";
+    hash = "sha256-j8B7g/w1Qtiuj099RlRLmrYTFiE7d2vVg/nTbaa8pRU=";
   };
 
-  nativeBuildInputs = [ pkg-config ];
+  nativeBuildInputs = [ installShellFiles pkg-config ];
 
   buildInputs = lib.optionals stdenv.isDarwin [ Security SystemConfiguration ];
 
-  cargoHash = "sha256-iuLhDcii+wXDNUsUMo8lj4kfJve5RAz7FT5Pxs9yFPQ=";
+  cargoHash = "sha256-WFGY5osZIEYeHQchvuE3ddeqh2wzfZNV+SGqW08zYDI=";
+
+  # Execute the resulting binary to generate shell completions, using emulation if necessary when cross-compiling.
+  # If no emulator is available, then give up on generating shell completions
+  postInstall =
+    let
+      vrc-get = "${stdenv.hostPlatform.emulator buildPackages} $out/bin/vrc-get";
+    in
+    lib.optionalString (stdenv.hostPlatform.emulatorAvailable buildPackages) ''
+      installShellCompletion --cmd vrc-get \
+        --bash <(${vrc-get} completion bash) \
+        --fish <(${vrc-get} completion fish) \
+        --zsh <(${vrc-get} completion zsh)
+    '';
 
   meta = with lib; {
     description = "Command line client of VRChat Package Manager, the main feature of VRChat Creator Companion (VCC)";