Skip to content

Add a configPath option #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 1, 2025
Merged

Conversation

sandydoo
Copy link
Member

@sandydoo sandydoo commented Mar 1, 2025

Adds a configPath option to allow changing the path to the generated pre-commit config (.pre-commit-config.yaml by default).

Fixes #345.

Based on #496.

diefans and others added 2 commits January 10, 2025 09:55
This fixes #345, by adding a `configFile` option to change the default
(`.pre-commit-config.yaml`) and so enables the parallel usage of devenv
and non-devenv maintained pre-commit hooks.
…ig-file-option

Rename `configFile` to `configPath` in #496.
@sandydoo sandydoo added the enhancement New feature or request label Mar 1, 2025
@sandydoo sandydoo merged commit 4a709a8 into master Mar 1, 2025
12 checks passed
@willfish
Copy link
Contributor

willfish commented Mar 1, 2025

Yay. Thanks for doing this

@zevisert
Copy link

Hey @sandydoo thanks for this! I've been annoyed by #345 for a while as well.. As a cachix/devenv user, would this work out of the box with devenv, or does devenv need a PR to enable this? I tried the following in my devenv.nix, but it doesn't seem to be working (no pre-commit configuration is created at .devenv/state/.pre-commit-config.yaml):

{
  config,
  ...
}: {
  git-hooks = {
    configPath = builtins.toPath (config.devenv.state + "/.pre-commit-config.yaml");
    hooks = {
      trim-trailing-whitespace.enable = true;
    };
  };
}

@sandydoo
Copy link
Member Author

@zevisert the path gets prefixed by the git working directory. We should make a note about this until we can support absolute paths as well. You can use a string for now, like ".devenv/state/.pre-commit-config.yaml".

@zevisert
Copy link

Ah, that was it - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[question] Can I use this to override a hook while leaving pre-commit-hooks.yaml alone for my non-nix-using colleagues?
4 participants