From 63d63d9a1feed302adf160cc67bcecf1222f4a81 Mon Sep 17 00:00:00 2001 From: eveeifyeve <88671402+Eveeifyeve@users.noreply.github.com> Date: Sun, 1 Mar 2026 21:55:46 +1100 Subject: [PATCH] clippy: init --- README.md | 3 ++- examples/formatter-clippy.toml | 6 +++++ programs/clippy.nix | 45 ++++++++++++++++++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 examples/formatter-clippy.toml create mode 100644 programs/clippy.nix diff --git a/README.md b/README.md index 6bd23c8..f0d3183 100644 --- a/README.md +++ b/README.md @@ -222,7 +222,7 @@ functions. -`treefmt-nix` currently supports 126 formatters: +`treefmt-nix` currently supports 128 formatters: * [actionlint](programs/actionlint.nix) * [aiken](programs/aiken.nix) @@ -238,6 +238,7 @@ functions. * [cabal-gild](programs/cabal-gild.nix) * [clang-format](programs/clang-format.nix) * [clang-tidy](programs/clang-tidy.nix) +* [clippy](programs/clippy.nix) * [cljfmt](programs/cljfmt.nix) * [cmake-format](programs/cmake-format.nix) * [csharpier](programs/csharpier.nix) diff --git a/examples/formatter-clippy.toml b/examples/formatter-clippy.toml new file mode 100644 index 0000000..022d98b --- /dev/null +++ b/examples/formatter-clippy.toml @@ -0,0 +1,6 @@ +# Example generated by ../examples.sh +[formatter.clippy] +command = "clippy" +excludes = [] +includes = ["*.rs"] +options = ["--edition", "2024"] diff --git a/programs/clippy.nix b/programs/clippy.nix new file mode 100644 index 0000000..4d85105 --- /dev/null +++ b/programs/clippy.nix @@ -0,0 +1,45 @@ +{ + lib, + config, + mkFormatterModule, + ... +}: +let + cfg = config.programs.clippy; +in +{ + meta.maintainers = [ + "DigitalBrewStudios/Treefmt-nix" + ]; + + imports = [ + (mkFormatterModule { + name = "clippy"; + mainProgram = "clippy"; + includes = [ "*.rs" ]; + }) + ]; + + options.programs.clippy = { + denyWarnings = lib.mkEnableOption "clippy to denyWarnings"; + edition = lib.mkOption { + type = lib.types.str; + default = "2024"; + description = '' + Rust edition to target when linting + ''; + }; + }; + + config = lib.mkIf cfg.enable { + settings.formatter.clippy = { + options = [ + "--edition" + cfg.edition + ] + ++ lib.optionals cfg.denyWarnings [ + "--deny-warnings" + ]; + }; + }; +}