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.
Markdown files are link-checked with lychee
using a shared base config (headers, accepted status codes, retries, per-host
throttling, and excludes for placeholder hosts such as http://dockerhost:8080).
- Repo-specific exclusions: add a
.lycheeignoreat the repo root, one regular expression per line. Matching URLs are skipped. - GitHub rate limits: set
GITHUB_TOKENin the environment that runs pre-commit (e.g.env: GITHUB_TOKEN: ${{ github.token }}on the CI lint step) so github.com links are checked through the API. - Nix sandbox: inside
nix flake checkthere is no network, so only local file links are checked there. - Opting out: pass
enableLinkCheck = falsetomkCheck.
GitHub Actions workflows are checked with actionlint using a shared config
(a repo-local .github/actionlint.yaml is not read). Repos with self-hosted
runners declare their labels on mkCheck:
extraActionlintRunnerLabels = [ "my-self-hosted-label" ];Example .lycheeignore:
^https://ais\.feed\.sdrmap\.org
^http://influxdb:8086
Placeholder URLs that are not valid URLs at all (such as
<http://dockerhost:port/>) cannot be excluded; write them as inline code
instead of links.
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!