about summary refs log tree commit diff
path: root/pkgs/by-name/as/ast-grep/package.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/as/ast-grep/package.nix')
-rw-r--r--pkgs/by-name/as/ast-grep/package.nix10
1 files changed, 10 insertions, 0 deletions
diff --git a/pkgs/by-name/as/ast-grep/package.nix b/pkgs/by-name/as/ast-grep/package.nix
index 9a80ef6751f2..c0fa05e30c16 100644
--- a/pkgs/by-name/as/ast-grep/package.nix
+++ b/pkgs/by-name/as/ast-grep/package.nix
@@ -2,6 +2,7 @@
 , rustPlatform
 , fetchFromGitHub
 , stdenv
+, installShellFiles
 }:
 
 rustPlatform.buildRustPackage rec {
@@ -22,11 +23,20 @@ rustPlatform.buildRustPackage rec {
     NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
   };
 
+  nativeBuildInputs = [ installShellFiles ];
+
   # error: linker `aarch64-linux-gnu-gcc` not found
   postPatch = ''
     rm .cargo/config.toml
   '';
 
+  postInstall = ''
+    installShellCompletion --cmd sg \
+      --bash <($out/bin/sg completions bash) \
+      --fish <($out/bin/sg completions fish) \
+      --zsh <($out/bin/sg completions zsh)
+  '';
+
   checkFlags = [
     # disable flaky test
     "--skip=test::test_load_parser_mac"