Pre-Commit Hooks
devenv has first-class integration for pre-commit via pre-commit-hooks.nix.
Set up
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 the .pre-commit-config.yaml file
The .pre-commit-config.yaml file is a symlink to an autogenerated file in your devenv Nix store.
It is not necessary to commit this file to your repository and it can safely be ignored.
This file name will be added to your .gitignore file by default when you run devenv init.