immich-tools/nix/git-hooks.nix

65 lines
1.5 KiB
Nix

{ 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;
};
};
};
}