Files
nix/git-hooks.nix
2026-02-07 14:25:39 +01:00

45 lines
811 B
Nix

{
nixpkgs,
git-hooks,
system,
src,
}:
let
pkgs = nixpkgs.legacyPackages.${system};
pre-commit-check = git-hooks.lib.${system}.run {
inherit src;
hooks = {
nixfmt.enable = true;
statix.enable = true;
deadnix.enable = true;
};
};
in
{
checks = {
inherit pre-commit-check;
};
formatter =
let
inherit (pre-commit-check) config;
inherit (config) package configFile;
script = ''
${pkgs.lib.getExe package} run --all-files --config ${configFile}
'';
in
pkgs.writeShellScriptBin "pre-commit-run" script;
devShells = {
default =
let
inherit (pre-commit-check) shellHook enabledPackages;
in
pkgs.mkShell {
inherit shellHook;
buildInputs = enabledPackages;
};
};
}