From 4ba6ee299813f380eb3769cc621980c6ec409b3b Mon Sep 17 00:00:00 2001 From: Sander Date: Fri, 25 Oct 2024 11:12:18 +0200 Subject: [PATCH] rust: override pre-commit packages from toolchain --- src/modules/languages/rust.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/modules/languages/rust.nix b/src/modules/languages/rust.nix index 48ba73bc2..df385f9fa 100644 --- a/src/modules/languages/rust.nix +++ b/src/modules/languages/rust.nix @@ -89,7 +89,7 @@ in config = lib.mkIf cfg.enable (lib.mkMerge [ ( let - mkOverrideTools = lib.mkOverride (lib.modules.defaultOverridePriority - 1); + mkOverrideTools = package: lib.mkIf (package != null) (lib.mkOverride (lib.modules.defaultOverridePriority - 1) package); in { assertions = [ @@ -145,6 +145,16 @@ in pre-commit.tools.cargo = mkOverrideTools cfg.toolchain.cargo or null; pre-commit.tools.rustfmt = mkOverrideTools cfg.toolchain.rustfmt or null; pre-commit.tools.clippy = mkOverrideTools cfg.toolchain.clippy or null; + + pre-commit.hooks.clippy.packageOverrides = { + cargo = mkOverrideTools cfg.toolchain.cargo or null; + clippy = mkOverrideTools cfg.toolchain.clippy or null; + }; + + pre-commit.hooks.rustfmt.packageOverrides = { + cargo = mkOverrideTools cfg.toolchain.cargo or null; + rustfmt = mkOverrideTools cfg.toolchain.rustfmt or null; + }; } )