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
This commit is contained in:
Kenichi Kamiya
2024-12-06 10:43:06 +09:00
parent 5eafabf8db
commit 81e6459faa
+13
View File
@@ -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;