summary refs log tree commit diff
diff options
context:
space:
mode:
authorMario Rodas <marsam@users.noreply.github.com>2023-11-18 23:50:58 -0500
committerGitHub <noreply@github.com>2023-11-18 23:50:58 -0500
commit227bf4382f49e21ff7147ffb8dafe51db8b59357 (patch)
tree5f77e6327e45df2b393fea8bab48f4f131989b35
parent1bde115d4fd827e91e8fa486eedd1046b269b6b4 (diff)
parentbfa27b35065f88e5a300829c8bc02926bcc0665f (diff)
downloadnixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.tar
nixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.tar.gz
nixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.tar.bz2
nixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.tar.lz
nixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.tar.xz
nixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.tar.zst
nixpkgs-227bf4382f49e21ff7147ffb8dafe51db8b59357.zip
Merge pull request #267061 from nix-julia/add-shell-completions-mdbook
mdbook: add shell completions
-rw-r--r--pkgs/tools/text/mdbook/default.nix11
1 files changed, 10 insertions, 1 deletions
diff --git a/pkgs/tools/text/mdbook/default.nix b/pkgs/tools/text/mdbook/default.nix
index e0529c77917..95483b8465e 100644
--- a/pkgs/tools/text/mdbook/default.nix
+++ b/pkgs/tools/text/mdbook/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenv, fetchFromGitHub, nix, rustPlatform, CoreServices }:
+{ lib, stdenv, fetchFromGitHub, nix, rustPlatform, CoreServices, installShellFiles }:
 
 rustPlatform.buildRustPackage rec {
   pname = "mdbook";
@@ -13,8 +13,17 @@ rustPlatform.buildRustPackage rec {
 
   cargoHash = "sha256-D0XhrweO0A1+81Je4JZ0lmnbIHstNvefpmogCyB4FEE=";
 
+  nativeBuildInputs = [ installShellFiles ];
+
   buildInputs = lib.optionals stdenv.isDarwin [ CoreServices ];
 
+  postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
+    installShellCompletion --cmd mdbook \
+      --bash <($out/bin/mdbook completions bash) \
+      --fish <($out/bin/mdbook completions fish) \
+      --zsh  <($out/bin/mdbook completions zsh )
+  '';
+
   passthru = {
     tests = {
       inherit nix;