Pre-Commit Hooks
devenv has first-class integration for pre-commit via pre-commit-hooks.nix.
Setup
We recommend a two-step approach for integrating your linters and formatters.
1) Make sure that commits are well-formatted at commit time
devenv.nix
{ inputs, ... }:
{
pre-commit.hooks = {
# lint shell scripts
shellcheck.enable = true;
# execute example shell from Markdown files
mdsh.enable = true;
# format Python code
black.enable = true;
};
}
In action:
If you commit a Python or Markdown file or a script, these hooks will run at commit time.
2) Verify formatting in CI
Run devenv ci.
See the list of all available hooks.
Managing .pre-commit-config.yaml file
The .pre-commit-config.yaml is a symlink to an autogenerated file in your Devenv's Nix Store.
It is not necessary to commit this file to your repository and can safely be ignored.
This filename will be added to your .gitignore file when running devenv init by default.