From bfa27b35065f88e5a300829c8bc02926bcc0665f Mon Sep 17 00:00:00 2001 From: nix-julia Date: Sun, 12 Nov 2023 18:24:43 +0330 Subject: mdbook: add shell completions --- pkgs/tools/text/mdbook/default.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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; -- cgit 1.4.1