Skip to content
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

fix: add configFile option #496

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

diefans
Copy link

@diefans diefans commented Sep 26, 2024

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.

This fixes cachix#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.
@sandydoo sandydoo added the enhancement New feature or request label Oct 10, 2024
@sandydoo
Copy link
Member

  1. There are a few more pre-commit calls in run that would need to be adjusted.
    run =
    runCommand "pre-commit-run" { buildInputs = [ git ]; } ''
    set +e
    HOME=$PWD
    # Use `chmod +w` instead of `cp --no-preserve=mode` to be able to write and to
    # preserve the executable bit at the same time
    cp -R ${cfg.rootSrc} src
    chmod -R +w src
    ln -fs ${configFile} src/.pre-commit-config.yaml
    cd src
    rm -rf .git
    git init -q
    git add .
    git config --global user.email "[email protected]"
    git config --global user.name "Your Name"
    git commit -m "init" -q
    if [[ ${toString (compare install_stages [ "manual" ])} -eq 0 ]]
    then
    echo "Running: $ pre-commit run --hook-stage manual --all-files"
    ${cfg.package}/bin/pre-commit run --hook-stage manual --all-files
    else
    echo "Running: $ pre-commit run --all-files"
    ${cfg.package}/bin/pre-commit run --all-files
    fi
    exitcode=$?
    git --no-pager diff --color
    mkdir $out
    [ $? -eq 0 ] && exit $exitcode
    '';
  2. I'm not sure about the name of the option. We may also need to expose configFile itself in the future, e.g. feat: update pre-commit.nix to be "run" customizable #494. Maybe configPath would be better?

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
2 participants