@@ -104,10 +104,10 @@ let
104104 if [[ ${ toString ( compare cfg . installStages [ "manual" ] ) } -eq 0 ]]
105105 then
106106 echo "Running: $ pre-commit run --hook-stage manual --all-files"
107- pre-commit run -c ${ cfg . configPath } --hook-stage manual --all-files
107+ ${ lib . getExe cfg . package } run -c ${ cfg . configPath } --hook-stage manual --all-files
108108 else
109109 echo "Running: $ pre-commit run --all-files"
110- pre-commit run -c ${ cfg . configPath } --all-files
110+ ${ lib . getExe cfg . package } run -c ${ cfg . configPath } --all-files
111111 fi
112112 exitcode=$?
113113 git --no-pager diff --color
144144 default = true ;
145145 description = ''
146146 Whether to enable the pre-commit hooks module.
147-
147+
148148 When set to false, this disables the entire module.
149149 '' ;
150150 } ;
155155 default = true ;
156156 description = ''
157157 Whether to enable automatic installation of pre-commit hooks.
158-
158+
159159 When set to false, hooks will not be installed into the git repository,
160160 but all other module functionality (like configuration generation) will still work.
161161 '' ;
441441
442442 installationScript =
443443 ''
444- export PATH=${ cfg . package } /bin:$PATH
445444 if ${ boolToString cfg . install . enable } ; then
446445 if ! ${ cfg . gitPackage } /bin/git rev-parse --git-dir &> /dev/null; then
447446 echo 1>&2 "WARNING: git-hooks.nix: .git not found; skipping installation."
448447 else
449- GIT_WC=`${ cfg . gitPackage } /bin/git rev-parse --show-toplevel`
448+ GIT_WC=`${ lib . getExe cfg . gitPackage } rev-parse --show-toplevel`
450449
451450 # These update procedures compare before they write, to avoid
452451 # filesystem churn. This improves performance with watch tools like lorri
474473 # Remove any previously installed hooks (since pre-commit itself has no convergent design)
475474 hooks="${ concatStringsSep " " ( remove "manual" supportedHooksLib . supportedHooks ) } "
476475 for hook in $hooks; do
477- pre-commit uninstall -t $hook
476+ ${ lib . getExe cfg . package } uninstall -t $hook
478477 done
479- ${ cfg . gitPackage } /bin/git config --local core.hooksPath ""
478+ ${ lib . getExe cfg . gitPackage } config --local core.hooksPath ""
480479 # Add hooks for configured stages (only) ...
481480 if [ ! -z "${ concatStringsSep " " install_stages } " ]; then
482481 for stage in ${ concatStringsSep " " install_stages } ; do
486485 # if you amend these switches please also review $hooks above
487486 commit | merge-commit | push)
488487 stage="pre-"$stage
489- pre-commit install -c ${ cfg . configPath } -t $stage
488+ ${ lib . getExe cfg . package } install -c ${ cfg . configPath } -t $stage
490489 ;;
491490 ${ concatStringsSep "|" supportedHooksLib . supportedHooks } )
492- pre-commit install -c ${ cfg . configPath } -t $stage
491+ ${ lib . getExe cfg . package } install -c ${ cfg . configPath } -t $stage
493492 ;;
494493 *)
495494 echo 1>&2 "ERROR: git-hooks.nix: either $stage is not a valid stage or git-hooks.nix doesn't yet support it."
499498 done
500499 # ... or default 'pre-commit' hook
501500 else
502- pre-commit install -c ${ cfg . configPath }
501+ ${ lib . getExe cfg . package } install -c ${ cfg . configPath }
503502 fi
504503
505504 # Fetch the absolute path to the git common directory. This will normally point to $GIT_WC/.git.
508507 # Convert the absolute path to a path relative to the toplevel working directory.
509508 common_dir='' ${common_dir#'' $GIT_WC/}
510509
511- ${ cfg . gitPackage } /bin/git config --local core.hooksPath "'' $common_dir/hooks"
510+ ${ lib . getExe cfg . gitPackage } config --local core.hooksPath "'' $common_dir/hooks"
512511 fi
513512 fi
514513 fi
0 commit comments