chore: improve Nix flake

This commit is contained in:
Marc Plano-Lesay 2025-08-01 11:35:27 +10:00
parent e9231986c3
commit 7836888456
Signed by: kernald
GPG key ID: 66A41B08CC62A6CF
6 changed files with 208 additions and 20 deletions

65
nix/git-hooks.nix Normal file
View file

@ -0,0 +1,65 @@
{ inputs, pkgs, ... }:
let
conventional-commit = pkgs.callPackage ./pkgs/conventional-pre-commit.nix { };
in
{
pre-commit-check = inputs.pre-commit-hooks.lib.${pkgs.system}.run {
src = ./..;
hooks = {
# TOML
check-toml.enable = true;
# YAML
check-yaml.enable = true;
# Nix
deadnix.enable = true;
flake-checker.enable = true;
nixpkgs-fmt.enable = true;
statix.enable = true;
# Rust
clippy = {
enable = true;
settings = {
denyWarnings = true;
};
extraPackages = with pkgs; [
openssl
pkg-config
];
};
rustfmt.enable = true;
cargo-check = {
enable = true;
extraPackages = with pkgs; [
pkg-config
openssl
];
};
# Git
no-commit-to-branch = {
enable = true;
settings = {
branch = [ "main" ];
};
};
conventional-commit = {
enable = true;
name = "conventional-commit";
description = "A pre-commit hook that checks commit messages for Conventional Commits formatting";
package = conventional-commit;
entry = "${conventional-commit}/bin/conventional-pre-commit";
args = [ "--strict" "feat" "fix" "chore" "revert" "style" "docs" "build" "refactor" "test" "ci" "perf" ];
stages = [ "commit-msg" ];
};
};
settings = {
rust.check.cargoDeps = pkgs.rustPlatform.importCargoLock {
lockFile = ../Cargo.lock;
};
};
};
}