From 59a1021410a28b635d86cde34da75766204f2f7e Mon Sep 17 00:00:00 2001 From: Lorenz Leutgeb Date: Mon, 28 Apr 2025 14:19:58 +0200 Subject: [PATCH] hook: Make `cargo check` and `cargo clippy` only execute pre-push These hook take relatively long on my machine, and my impatience has lead to me doing `git commit --no-verify`, which defeats the purpose of having these hooks. Note that others (like `alejandra`, `cargo fmt` and `shellcheck`) are reasonably fast and will keep doing good. --- flake.lock | 48 ++++++++++++++++++++++++------------------------ flake.nix | 10 +++++++--- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/flake.lock b/flake.lock index 7bf9c83f..edd008e3 100644 --- a/flake.lock +++ b/flake.lock @@ -65,10 +65,32 @@ "type": "github" } }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1742649964, + "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, "gitignore": { "inputs": { "nixpkgs": [ - "pre-commit-hooks", + "git-hooks", "nixpkgs" ] }, @@ -118,39 +140,17 @@ "type": "github" } }, - "pre-commit-hooks": { - "inputs": { - "flake-compat": "flake-compat", - "gitignore": "gitignore", - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1742649964, - "narHash": "sha256-DwOTp7nvfi8mRfuL1escHDXabVXFGT1VlPD1JHrtrco=", - "owner": "cachix", - "repo": "git-hooks.nix", - "rev": "dcf5072734cb576d2b0c59b2ac44f5050b5eac82", - "type": "github" - }, - "original": { - "owner": "cachix", - "repo": "git-hooks.nix", - "type": "github" - } - }, "root": { "inputs": { "advisory-db": "advisory-db", "crane": "crane", "flake-utils": "flake-utils", + "git-hooks": "git-hooks", "nixpkgs": [ "nixpkgs-stable" ], "nixpkgs-stable": "nixpkgs-stable", "nixpkgs-unstable": "nixpkgs-unstable", - "pre-commit-hooks": "pre-commit-hooks", "rust-overlay": "rust-overlay" } }, diff --git a/flake.nix b/flake.nix index 4cfa9f78..418ee34b 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,7 @@ crane.url = "github:ipetkov/crane"; - pre-commit-hooks = { + git-hooks = { url = "github:cachix/git-hooks.nix"; inputs.nixpkgs.follows = "nixpkgs"; }; @@ -108,15 +108,19 @@ # Set of checks that are run: `nix flake check` checks = { - pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run { + pre-commit-check = inputs.git-hooks.lib.${system}.run { src = ./.; settings.rust.check.cargoDeps = pkgs.rustPlatform.importCargoLock {lockFile = ./Cargo.lock;}; hooks = { alejandra.enable = true; rustfmt.enable = true; - cargo-check.enable = true; + cargo-check = { + enable = true; + stages = ["pre-push"]; + }; clippy = { enable = true; + stages = ["pre-push"]; settings.denyWarnings = true; packageOverrides.cargo = rustToolchain; packageOverrides.clippy = rustToolchain;