Skip to content

Commit

Permalink
rust: override pre-commit packages from toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
sandydoo committed Oct 25, 2024
1 parent abdb30a commit 4ba6ee2
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/modules/languages/rust.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -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;
};
}
)

Expand Down

0 comments on commit 4ba6ee2

Please sign in to comment.