Skip to content

fix(workspace): never deploy template pre-commit YAML over flake-generated hooks - #1259

Merged
c-vigo merged 4 commits into
release/1.4.1from
bugfix/1255-upgrade-precommit-template-direnv
Jul 23, 2026
Merged

c-vigo merged 4 commits into
release/1.4.1from
bugfix/1255-upgrade-precommit-template-direnv

Conversation

@c-vigo

@c-vigo c-vigo commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

An install.sh --force upgrade on a flake-hooks consumer deployed the scaffold
template .pre-commit-config.yaml whenever the file was absent from the tree.
On such a consumer the config is flake-GENERATED (#1167/#883): a gitignored
/nix/store symlink that only materializes on shell entry, so a fresh
checkout/worktree legitimately has no file for the preserve list to protect.
The deployed template then SHADOWED the generated config — git-hooks.nix
refuses to overwrite an existing file — silently dropping the consumer's
hooks/hooksExcludes customizations (observed on commit-action: typos ran
against the committed dist/ bundle).

Fix

The opt-in is detectable without the file: an ACTIVE (uncommented)
hooks/hooksExcludes argument in the preserved flake.nix — exactly
mkProjectShell's generation trigger (hooks != null || hooksExcludes != [ ]);
the template's commented opt-in block never matches.

Targeted at release/1.4.1: pre-existing since 1.4.0, but it bites every
fresh-worktree upgrade of the direnv lanes, so it rides the patch train.

Verification

  • New bats coverage (5 tests): upgrade with absent generated config deploys no
    template YAML and keeps the gitignore entry; hooksExcludes-only opt-in is
    detected; a flake with only the COMMENTED template opt-in still receives the
    template YAML; --preview no longer advertises the file as ADDED.
  • Full tests/bats/init-workspace.bats suite: 243/243 green.
  • just precommit: all hooks green except the pre-existing, unrelated
    check-expirations failure (curl 8.20.0 batch expired 2026-07-22 — filed
    separately; it will also fail this PR's CI until resolved).

Closes #1255

@c-vigo
c-vigo merged commit 33c8fdc into release/1.4.1 Jul 23, 2026
13 checks passed
@c-vigo
c-vigo deleted the bugfix/1255-upgrade-precommit-template-direnv branch July 23, 2026 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant