about summary refs log tree commit diff
diff options
context:
space:
mode:
authoraktaboot <akhtaboot@protonmail.com>2024-07-17 20:25:13 +0200
committerJohn Titor <50095635+JohnRTitor@users.noreply.github.com>2024-07-18 21:36:15 +0530
commit6caafcba3bdccda8cf32eeef91a23d323b42c797 (patch)
treecd5077f1f7787fdb01e2095e1a481f6e0d1a77e9
parent419861aa4d0828fc3f04602fbe3f43ebf26cac9e (diff)
bcachefs-tools: add fish,bash,zsh completions
-rw-r--r--pkgs/by-name/bc/bcachefs-tools/package.nix19
1 files changed, 14 insertions, 5 deletions
diff --git a/pkgs/by-name/bc/bcachefs-tools/package.nix b/pkgs/by-name/bc/bcachefs-tools/package.nix
index f145834ba7e8f..7794c2bab8761 100644
--- a/pkgs/by-name/bc/bcachefs-tools/package.nix
+++ b/pkgs/by-name/bc/bcachefs-tools/package.nix
@@ -22,6 +22,7 @@
   nix-update-script,
   python3,
   fetchpatch,
+  installShellFiles,
   fuseSupport ? false,
 }:
 
@@ -43,6 +44,7 @@ stdenv.mkDerivation (finalAttrs: {
     rustPlatform.cargoSetupHook
     rustPlatform.bindgenHook
     makeWrapper
+    installShellFiles
   ];
 
   buildInputs = [
@@ -94,10 +96,17 @@ stdenv.mkDerivation (finalAttrs: {
     "PKGCONFIG_UDEVDIR=$(out)/lib/udev"
   ];
 
-  postInstall = ''
-    substituteInPlace $out/libexec/bcachefsck_all \
-      --replace-fail "/usr/bin/python3" "${python3}/bin/python3"
-  '';
+  postInstall =
+    ''
+      substituteInPlace $out/libexec/bcachefsck_all \
+        --replace-fail "/usr/bin/python3" "${python3}/bin/python3"
+    ''
+    + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+      installShellCompletion --cmd bcachefs \
+        --bash <($out/sbin/bcachefs completions bash) \
+        --zsh  <($out/sbin/bcachefs completions zsh) \
+        --fish <($out/sbin/bcachefs completions fish)
+    '';
 
   passthru = {
     tests = {
@@ -105,7 +114,7 @@ stdenv.mkDerivation (finalAttrs: {
       inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti;
     };
 
-    updateScript = nix-update-script {};
+    updateScript = nix-update-script { };
   };
 
   enableParallelBuilding = true;