From 95693d45b20c08122c9b9cdcb259f9c70d233522 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Mon, 24 Nov 2025 18:09:53 +0100 Subject: [PATCH] run cargo fmt as a nix derivation --- .woodpecker/debug.yaml | 2 +- flake.nix | 8 ++++++++ nix/compile.nix | 11 +++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/.woodpecker/debug.yaml b/.woodpecker/debug.yaml index 0f60b4e3..4dc7d3c9 100644 --- a/.woodpecker/debug.yaml +++ b/.woodpecker/debug.yaml @@ -14,7 +14,7 @@ steps: - name: check formatting image: nixpkgs/nix:nixos-24.05 commands: - - nix-shell --attr devShell --run "cargo fmt -- --check" + - nix-build -j4 --attr flakePackages.fmt - name: build image: nixpkgs/nix:nixos-24.05 diff --git a/flake.nix b/flake.nix index 48880347..01a077c4 100644 --- a/flake.nix +++ b/flake.nix @@ -30,6 +30,10 @@ inherit system nixpkgs crane rust-overlay extraTestEnv; release = false; }).garage-test; + lints = (compile { + inherit system nixpkgs crane rust-overlay; + release = false; + }); in { packages = { @@ -56,6 +60,10 @@ tests-fjall = testWith { GARAGE_TEST_INTEGRATION_DB_ENGINE = "fjall"; }; + + # lints (fmt, clippy) + fmt = lints.garage-cargo-fmt; + clippy = lints.garage-cargo-clippy; }; # ---- developpment shell, for making native builds only ---- diff --git a/nix/compile.nix b/nix/compile.nix index 5a49526f..c6df9dbd 100644 --- a/nix/compile.nix +++ b/nix/compile.nix @@ -190,4 +190,15 @@ in rec { pkgs.cacert ]; } // extraTestEnv); + + # ---- source code linting ---- + + garage-cargo-fmt = craneLib.cargoFmt (commonArgs // { + cargoExtraArgs = ""; + }); + + garage-cargo-clippy = craneLib.cargoClippy (commonArgs // { + cargoArtifacts = garage-deps; + cargoClippyExtraArgs = "--all-targets -- -D warnings"; + }); }