From 71afd373b18a5018b6d725442b4004ddd61c79a2 Mon Sep 17 00:00:00 2001 From: Tom Hunze Date: Mon, 26 Jan 2026 22:15:08 +0100 Subject: [PATCH] prek: add shell completions https://prek.j178.dev/installation/#shell-completion --- pkgs/by-name/pr/prek/package.nix | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkgs/by-name/pr/prek/package.nix b/pkgs/by-name/pr/prek/package.nix index c4b42b2ce913..b12fa0ad8c44 100644 --- a/pkgs/by-name/pr/prek/package.nix +++ b/pkgs/by-name/pr/prek/package.nix @@ -1,7 +1,9 @@ { lib, + stdenv, fetchFromGitHub, rustPlatform, + installShellFiles, git, uv, python312, @@ -22,6 +24,10 @@ rustPlatform.buildRustPackage (finalAttrs: { cargoHash = "sha256-KOpQ3P9cmcWYT3bPKtKpzHPagX4b9hH0EiWGpt98NnE="; + nativeBuildInputs = [ + installShellFiles + ]; + nativeCheckInputs = [ git python312 @@ -174,6 +180,13 @@ rustPlatform.buildRustPackage (finalAttrs: { "version_info" ]; + postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' + installShellCompletion --cmd prek \ + --bash <(COMPLETE=bash $out/bin/prek) \ + --fish <(COMPLETE=fish $out/bin/prek) \ + --zsh <(COMPLETE=zsh $out/bin/prek) + ''; + doInstallCheck = true; nativeInstallCheckInputs = [ versionCheckHook ];