From 207b880608d332da7fdb8fc4e7d21278d0a7be61 Mon Sep 17 00:00:00 2001 From: JacobPEvans <20714140+JacobPEvans-personal@users.noreply.github.com> Date: Sat, 30 May 2026 22:50:26 -0400 Subject: [PATCH] fix(devshell): warn before pre-commit installer hits core.hooksPath block MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pre-commit's installer refuses with "Cowardly refusing to install hooks with core.hooksPath set" when any scope sets the value. The root cause (global core.hooksPath in nix-home) is being removed in dryvist/nix-home#272, but a defensive guard here surfaces a clear, actionable warning if any future regression — global, local, or per-machine drift — sets the value again. Without the guard the user sees the raw stderr twice per direnv activation with no hint that the fix is `git config --unset core.hooksPath`. The guard runs before installationScript; if hooksPath is empty it is a single grep-and-exit, so no perceptible startup cost. Refs: dryvist/nix-home#272 Assisted-by: Claude --- flake/dev-shell.nix | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/flake/dev-shell.nix b/flake/dev-shell.nix index 6994787..227972d 100644 --- a/flake/dev-shell.nix +++ b/flake/dev-shell.nix @@ -8,7 +8,18 @@ _: { { devShells.default = pkgs.mkShell { inputsFrom = [ config.treefmt.build.devShell ]; - shellHook = config.pre-commit.installationScript; + # Warn before pre-commit's installer fires: a set core.hooksPath + # makes it refuse with "Cowardly refusing to install hooks with + # core.hooksPath set". The fix is to unset, not to bypass. + shellHook = '' + if [ -n "$(git config --get core.hooksPath 2>/dev/null)" ]; then + echo "WARN: core.hooksPath is set to '$(git config --get core.hooksPath)'." >&2 + echo " pre-commit install will refuse. Unset it:" >&2 + echo " git config --unset core.hooksPath # local" >&2 + echo " git config --global --unset core.hooksPath # global" >&2 + fi + ${config.pre-commit.installationScript} + ''; packages = with pkgs; [ nixfmt-rfc-style nil