From 25bd0c856bc005a3a70c0c590b4e486329bb80bb Mon Sep 17 00:00:00 2001 From: magicquark <198001825+magicquark@users.noreply.github.com> Date: Mon, 8 Sep 2025 02:57:45 +0100 Subject: [PATCH] taplo: add shell completions - Version 0.10.0 of Taplo CLI added the ability to generate completions for shells (see https://github.com/tamasfe/taplo/releases/tag/0.10.0). - This commit adds the generated shell completions to the derivation output. - Resolves https://github.com/NixOS/nixpkgs/issues/440875. --- pkgs/by-name/ta/taplo/package.nix | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkgs/by-name/ta/taplo/package.nix b/pkgs/by-name/ta/taplo/package.nix index 7ce7f2367aa0..c38f2ba1816a 100644 --- a/pkgs/by-name/ta/taplo/package.nix +++ b/pkgs/by-name/ta/taplo/package.nix @@ -1,10 +1,12 @@ { + stdenv, lib, rustPlatform, fetchCrate, pkg-config, openssl, withLsp ? true, + installShellFiles, }: rustPlatform.buildRustPackage rec { @@ -20,6 +22,7 @@ rustPlatform.buildRustPackage rec { cargoHash = "sha256-tvijtB5fwOzQnnK/ClIvTbjCcMeqZpXcRdWWKZPIulM="; nativeBuildInputs = [ + installShellFiles pkg-config ]; @@ -29,6 +32,21 @@ rustPlatform.buildRustPackage rec { buildFeatures = lib.optional withLsp "lsp"; + postInstall = + lib.optionalString + ( + stdenv.buildPlatform.canExecute stdenv.hostPlatform + && + # Creation of the completions fails on Darwin platforms. + !stdenv.hostPlatform.isDarwin + ) + '' + installShellCompletion --cmd taplo \ + --bash <($out/bin/taplo completions bash) \ + --fish <($out/bin/taplo completions fish) \ + --zsh <($out/bin/taplo completions zsh) + ''; + meta = with lib; { description = "TOML toolkit written in Rust"; homepage = "https://taplo.tamasfe.dev";