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

Per-hook flake output check derivations #438

Open
gekoke opened this issue Apr 24, 2024 · 1 comment
Open

Per-hook flake output check derivations #438

gekoke opened this issue Apr 24, 2024 · 1 comment
Labels
enhancement New feature or request flake Related to running in pure environments

Comments

@gekoke
Copy link

gekoke commented Apr 24, 2024

It would be nice if each hook could be built as a separate derivation. Currently, only one flake check output with the name pre-commit is produced.

If the hooks could be split into separate derivations, one could:

Is this something that is possible to implement? I understand there is the upstream dependency on pre-commit-hooks that might come into play here.

@sandydoo
Copy link
Member

I suppose so. One thing to keep in mind is that there'll be a setup cost to pay for each check, not to mention the cost of launching a whole new job for each check.

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
touch $out
[ $? -eq 0 ] && exit $exitcode
'';

@sandydoo sandydoo added enhancement New feature or request flake Related to running in pure environments labels May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request flake Related to running in pure environments
Projects
None yet
Development

No branches or pull requests

2 participants