2024-05-19 23:32:52 -04:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
forEachSystem,
|
|
|
|
formatter,
|
|
|
|
...
|
|
|
|
}:
|
|
|
|
forEachSystem (system: {
|
|
|
|
pre-commit-check = inputs.pre-commit-hooks.lib.${system}.run {
|
|
|
|
src = ./.;
|
|
|
|
hooks = {
|
|
|
|
# nix checks
|
2024-05-20 01:06:40 -04:00
|
|
|
# Example custom hook for nix formatting
|
2024-05-19 23:32:52 -04:00
|
|
|
fmt-check = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# The command to execute (mandatory):
|
|
|
|
entry = "${formatter.${system}}/bin/nixfmt --check";
|
|
|
|
|
|
|
|
# The pattern of files to run on (default: "" (all))
|
|
|
|
# see also https://pre-commit.com/#hooks-files
|
|
|
|
files = "\\.nix$";
|
|
|
|
};
|
2024-05-20 01:06:40 -04:00
|
|
|
## static analysis checks for nix
|
2024-05-19 23:32:52 -04:00
|
|
|
nil.enable = true;
|
2024-05-21 19:43:57 -04:00
|
|
|
statix.enable = true;
|
2024-05-19 23:32:52 -04:00
|
|
|
|
|
|
|
# json hooks
|
2024-05-19 23:44:59 -04:00
|
|
|
check-json = {
|
|
|
|
enable = true;
|
|
|
|
# exclude vscode json files as they allow comments and check-json doesn't
|
|
|
|
excludes = [ "settings.json$" ];
|
|
|
|
};
|
2024-05-19 23:32:52 -04:00
|
|
|
|
2024-05-20 00:07:52 -04:00
|
|
|
# toml hooks
|
|
|
|
check-toml.enable = true;
|
|
|
|
|
2024-05-19 23:32:52 -04:00
|
|
|
# git hooks
|
|
|
|
check-merge-conflicts.enable = true;
|
2024-05-20 01:06:40 -04:00
|
|
|
## prevents committing to main
|
2024-05-19 23:32:52 -04:00
|
|
|
no-commit-to-branch.enable = true;
|
|
|
|
|
|
|
|
# misc hooks
|
|
|
|
check-added-large-files.enable = true;
|
2024-05-20 01:06:40 -04:00
|
|
|
## prevents two similarly named files for case sensitive systems
|
2024-05-19 23:32:52 -04:00
|
|
|
check-case-conflicts.enable = true;
|
|
|
|
detect-private-keys.enable = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})
|