From 75a58e9829ef83ff441a1de3d013165ef0fa2c06 Mon Sep 17 00:00:00 2001 From: Winter Date: Sat, 23 Jul 2022 16:03:49 -0400 Subject: [PATCH] Fix rustfmt and Clippy hooks --- modules/hooks.nix | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/modules/hooks.nix b/modules/hooks.nix index 43fbbdda..b97badb7 100644 --- a/modules/hooks.nix +++ b/modules/hooks.nix @@ -306,18 +306,40 @@ in entry = "${tools.yamllint}/bin/yamllint"; }; rustfmt = + let + wrapper = pkgs.symlinkJoin { + name = "rustfmt-wrapped"; + paths = [ tools.rustfmt ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/cargo-fmt \ + --prefix PATH : ${lib.makeBinPath [ tools.cargo ]} + ''; + }; + in { name = "rustfmt"; description = "Format Rust code."; - entry = "${tools.rustfmt}/bin/cargo-fmt fmt -- --check --color always"; + entry = "${wrapper}/bin/cargo-fmt fmt -- --check --color always"; files = "\\.rs$"; pass_filenames = false; }; clippy = + let + wrapper = pkgs.symlinkJoin { + name = "clippy-wrapped"; + paths = [ tools.clippy ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/cargo-clippy \ + --prefix PATH : ${lib.makeBinPath [ tools.cargo ]} + ''; + }; + in { name = "clippy"; description = "Lint Rust code."; - entry = "${tools.clippy}/bin/cargo-clippy clippy"; + entry = "${wrapper}/bin/cargo-clippy clippy"; files = "\\.rs$"; pass_filenames = false; };