From 81e6459faa779904cc0c50b6d7a6bcd5104c90aa Mon Sep 17 00:00:00 2001 From: Kenichi Kamiya Date: Fri, 6 Dec 2024 10:43:06 +0900 Subject: [PATCH] dprint: add shell completions The completion feature was introduced in version 0.39.0 - https://github.com/dprint/dprint/releases/tag/0.39.0 - https://github.com/dprint/dprint/commit/717546b0d7268f3b95b0047ca4a941cc94125dc2 --- pkgs/by-name/dp/dprint/package.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/by-name/dp/dprint/package.nix b/pkgs/by-name/dp/dprint/package.nix index 5cf6abe3633c..6cfb7183c78e 100644 --- a/pkgs/by-name/dp/dprint/package.nix +++ b/pkgs/by-name/dp/dprint/package.nix @@ -3,6 +3,7 @@ stdenv, fetchCrate, rustPlatform, + installShellFiles, testers, nix-update-script, dprint, @@ -23,6 +24,18 @@ rustPlatform.buildRustPackage rec { # every commit upstream on GitHub Actions doCheck = false; + nativeBuildInputs = lib.optionals (stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + installShellFiles + ]; + + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + export DPRINT_CACHE_DIR="$(mktemp -d)" + installShellCompletion --cmd dprint \ + --bash <($out/bin/dprint completions bash) \ + --zsh <($out/bin/dprint completions zsh) \ + --fish <($out/bin/dprint completions fish) + ''; + passthru = { tests.version = testers.testVersion { inherit version;