From 2a780f5572392f8a456b692dc58c0daa2d5f536e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Sun, 3 Sep 2023 17:31:42 +0200 Subject: [PATCH] commitizen: add shell completions Co-authored-by: Artturi --- .../version-management/commitizen/default.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkgs/applications/version-management/commitizen/default.nix b/pkgs/applications/version-management/commitizen/default.nix index 1db75b0d2d4e..9c38e05320a9 100644 --- a/pkgs/applications/version-management/commitizen/default.nix +++ b/pkgs/applications/version-management/commitizen/default.nix @@ -3,6 +3,8 @@ , fetchFromGitHub , git , python3 +, stdenv +, installShellFiles , testers }: @@ -25,6 +27,7 @@ python3.pkgs.buildPythonApplication rec { nativeBuildInputs = with python3.pkgs; [ poetry-core pythonRelaxDepsHook + installShellFiles ]; propagatedBuildInputs = with python3.pkgs; [ @@ -77,6 +80,18 @@ python3.pkgs.buildPythonApplication rec { "test_commitizen_debug_excepthook" ]; + postInstall = + let + argcomplete = lib.getExe' python3.pkgs.argcomplete "register-python-argcomplete"; + in + lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) + '' + installShellCompletion --cmd cz \ + --bash <(${argcomplete} --shell bash $out/bin/cz) \ + --zsh <(${argcomplete} --shell zsh $out/bin/cz) \ + --fish <(${argcomplete} --shell fish $out/bin/cz) + ''; + passthru = { tests.version = testers.testVersion { package = commitizen;