From f7cb50b3cfd4c6c4be75f5e33172021be562a49b Mon Sep 17 00:00:00 2001 From: wzy <32936898+Freed-Wu@users.noreply.github.com> Date: Tue, 4 Apr 2023 04:15:12 +0800 Subject: [PATCH] trash-cli: use installShellCompletion --- pkgs/tools/misc/trash-cli/default.nix | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkgs/tools/misc/trash-cli/default.nix b/pkgs/tools/misc/trash-cli/default.nix index fdc99fcfaa00..48bb79467cd8 100644 --- a/pkgs/tools/misc/trash-cli/default.nix +++ b/pkgs/tools/misc/trash-cli/default.nix @@ -1,4 +1,4 @@ -{ lib, fetchFromGitHub, python3Packages }: +{ lib, fetchFromGitHub, installShellFiles, python3Packages }: python3Packages.buildPythonApplication rec { pname = "trash-cli"; @@ -13,6 +13,11 @@ python3Packages.buildPythonApplication rec { propagatedBuildInputs = with python3Packages; [ psutil six ]; + nativeBuildInputs = with python3Packages; [ + installShellFiles + shtab + ]; + nativeCheckInputs = with python3Packages; [ mock pytestCheckHook @@ -44,13 +49,10 @@ python3Packages.buildPythonApplication rec { runHook postInstallCheck ''; postInstall = '' - for bin in trash{,-{empty,list,put,restore}}; do - $out/bin/$bin --print-completion bash > $bin - install -Dm644 $bin -t $out/share/bash-completion/completions - $out/bin/$bin --print-completion zsh > _$bin - install -Dm644 _$bin -t $out/share/zsh/site-functions - $out/bin/$bin --print-completion tcsh > $bin.csh - install -Dm644 $bin.csh -t $out/etc/profile.d + for bin in trash-empty trash-list trash-restore trash-put trash; do + installShellCompletion --cmd "$bin" \ + --bash <("$out/bin/$bin" --print-completion bash) \ + --zsh <("$out/bin/$bin" --print-completion zsh) done '';