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.
This commit is contained in:
Lorenz Leutgeb 2025-04-28 14:19:58 +02:00 committed by Fintan Halpenny
parent 5553a14752
commit 59a1021410
2 changed files with 31 additions and 27 deletions

View File

@ -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"
}
},

View File

@ -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;