This repository provides a unified, reusable Nix flake that defines a standardized set of pre-commit checks for use across multiple repositories.
This is a work in progress.
It is designed to:
- Centralize linting logic
- Avoid duplication of
.pre-commit-config.yamlacross repos - Allow consumers to extend excludes without overriding the base behavior
- Provide consistent, reproducible formatting and linting everywhere
- YAML validation
- End‑of‑file fixer
- Mixed line ending fixer
- Trailing whitespace fixer
- Python (black, flake8)
- Nix (nixfmt, deadnix, statix)
- Shell (shellcheck)
- Dockerfiles (hadolint)
- Markdown / general formatting (prettier)
- Spell checking (codespell)
- GitHub Actions/workflow schema validation
Repositories consuming this flake can extend the base exclusion list:
extraExcludes = [
"^generated/"
"^dist/"
"^third-party/"
];This allows per‑repo customization without duplicating config.
Add the flake:
inputs.precommit-base.url = "github:FredSystems/pre-commit-checks";
inputs.nixpkgs.follows = "precommit-base";Then define a check in your flake:
checks.pre-commit =
precommit-base.lib.mkPrecommitCheck {
system = builtins.currentSystem;
src = ./.;
extraExcludes = [
"^dist/"
"^generated/"
];
};Run it with:
nix flake checkThis repository provides its own development shell via:
nix developIncludes tools such as:
- pre-commit
- deadnix
- statix
- nixfmt
- codespell
- markdownlint
pre-commit-checks/
├── flake.nix
└── README.md ← you are here| Attribute | Description |
|---|---|
lib.mkPrecommitCheck |
Main function for generating per‑repo pre-commit checks |
MIT License unless otherwise stated.
Issues and PRs are welcome! If you want additional hook bundles (Rust, Python, Go), open an issue.
Ping me anytime—happy to help you wire this into your repos!