Skip to content

refactor(nix): split out the git wt module and auto-install JS deps on shell entry - #1543

Merged
ryoppippi merged 2 commits into
mainfrom
shell-hook
Jul 29, 2026
Merged

refactor(nix): split out the git wt module and auto-install JS deps on shell entry#1543
ryoppippi merged 2 commits into
mainfrom
shell-hook

Conversation

@ryoppippi

@ryoppippi ryoppippi commented Jul 29, 2026

Copy link
Copy Markdown
Member

Summary

Two dev-shell changes. First, the git wt repo config moves out of nix/dev-shell.nix into its own nix/git-wt.nix module, matching the layout rorkai/rork-local already uses. Second, the dev shell now installs JS dependencies itself when a lockfile is newer than the last install.

What Changed

  • Add nix/git-wt.nix: takes pkgs and an installCommand (default just install) and returns the wt.hook / wt.remover / wt.deletehook shellHook fragment. The expanded hook is byte-identical to before.
  • nix/dev-shell.nix: imports that module and appends it to shellHook; adds a guarded auto-install ahead of the agent-skill sync.
  • justfile: just install now writes node_modules/.install-stamp, which is what the dev shell checks.

Why

Entering the shell after a git pull that bumped a lockfile left a stale node_modules until someone remembered to run just install — usually surfacing as a confusing type or resolution error rather than as a missing dependency.

The stamp file, rather than the node_modules mtimes, is what makes the check reliable: an install that changes nothing leaves those directory mtimes untouched, so comparing against the tree itself would re-install on every shell entry. Because just install owns the stamp, the git wt worktree hook already satisfies the check and a fresh worktree does not install twice.

The check also covers nix/tools/*/bun.lock, since those tool directories sit outside the pnpm workspace and .envrc already watches the whole nix/ tree.

Testing

  • nix fmt — no changes
  • nix eval .#devShells.aarch64-darwin.default.shellHook — the git wt config expands identically to the pre-refactor shellHook
  • Live direnv reloads on macOS covering each guard branch:
    • stamp missing → installs, stamp created
    • stamp fresh → skipped, no output
    • touch nix/tools/publint/bun.lock → direnv re-enters and installs, then settles back to skipping

View with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is enabled.


Summary by cubic

Split the git wt worktree wiring into its own Nix module and added auto-install of JS dependencies on dev shell entry when lockfiles change. This prevents stale node_modules after pulls and keeps the shell hook easier to read.

  • Refactors

    • Moved git wt wiring to nix/git-wt.nix; imported from nix/dev-shell.nix. The module accepts an installCommand (default just install) and emits the same wt.hook/remover/deletehook as before.
  • New Features

    • Dev shell installs JS deps when any lockfile is newer than node_modules/.install-stamp. just install now writes the stamp and covers pnpm-lock.yaml and nix/tools/*/bun.lock.

Written for commit 02891ee. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • New Features

    • Development environments now automatically install JavaScript dependencies when lockfiles change.
    • New worktree hooks streamline environment setup and cleanup, including dependency installation and safer removal of worktree directories.
  • Improvements

    • Worktree cleanup now also refreshes local environment settings and performs garbage collection.
    • Hook failures no longer interrupt worktree operations.

The dev shell's shellHook mixed three unrelated concerns: mold linker
flags, agent-skill syncing, and the `git wt` repo config. Move the last
one to nix/git-wt.nix, matching the layout rorkai/rork-local already
uses, so the two repositories can stay in sync and the dev shell reads
as a list of concerns rather than a script.

The module takes the worktree install command as an argument, defaulting
to `just install`, which is what this repository needs. The expanded
shellHook is byte-identical to before.
Entering the dev shell after a `git pull` that bumped a lockfile left a
stale node_modules until someone remembered to run `just install`, which
usually surfaced as a confusing type or resolution error rather than as a
missing dependency.

Gate the install on a stamp file instead of on the node_modules mtimes:
an install that changes nothing leaves those directories untouched, so
comparing against the tree itself would re-install on every shell entry.
`just install` writes the stamp, which also means the `git wt` worktree
hook already satisfies the check and a fresh worktree does not install
twice.

The check covers the tool lockfiles under nix/tools as well, since those
directories sit outside the pnpm workspace and `.envrc` already watches
the whole nix/ tree.
Copilot AI review requested due to automatic review settings July 29, 2026 16:44
@pullfrog

pullfrog Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor
  • Read the complete PR diff end-to-end using TOC line ranges
  • Read pullfrog-summary.md, learnings, and surrounding context
  • Triage the PR — identify domain, seams, external contracts
  • Decide on specialist dispatch (if any hypotheses remain)
  • Aggregate findings, draft review
  • Submit review via pullfrog_create_pull_request_review

Pullfrog  | ⚠️ this action is pinned to a commit SHA, which freezes the cleanup step — switch to @v0 or keep the SHA fresh with Dependabot | View workflow run | via Pullfrog | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The dev shell now detects stale JavaScript dependencies using an installation stamp and configures git wt lifecycle hooks through a reusable Nix module. The install recipe updates the stamp after dependency installation.

Changes

Dev shell dependency and worktree automation

Layer / File(s) Summary
Dependency freshness tracking
justfile, nix/dev-shell.nix
The install recipe touches node_modules/.install-stamp, while the dev shell runs just install when configured lockfiles are newer than the stamp.
Reusable worktree hook integration
nix/git-wt.nix, nix/dev-shell.nix
A new Nix function configures dependency installation, worktree cleanup, and direnv/Nix state cleanup hooks, which are appended to the dev shell hook.
Estimated code review effort: 2 (Simple) ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Developer
  participant DevShell
  participant JustInstall
  participant GitWt
  participant Worktree
  Developer->>DevShell: Enter development shell
  DevShell->>DevShell: Compare lockfiles with install stamp
  DevShell->>JustInstall: Run installation when lockfiles are newer
  Developer->>GitWt: Create or delete worktree
  GitWt->>Worktree: Run configured lifecycle hooks
  Worktree->>JustInstall: Install dependencies for new worktree
Loading

Possibly related PRs

Suggested reviewers: copilot, pullfrog

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main refactor and the new auto-install behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch shell-hook

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ccusage-guide 02891ee Commit Preview URL

Branch Preview URL
Jul 29 2026, 04:46 PM

@ryoppippi
ryoppippi merged commit 28d54f9 into main Jul 29, 2026
16 of 17 checks passed
@ryoppippi
ryoppippi deleted the shell-hook branch July 29, 2026 16:46

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@nix/dev-shell.nix`:
- Around line 92-100: The needsInstall check must detect deleted lockfiles as
well as modified or newer ones. Update the lockfile tracking logic around the
needsInstall initialization and lock iteration to compare the current lockfile
path/content fingerprint against the state recorded in
node_modules/.install-stamp, so additions, deletions, and changes to
pnpm-lock.yaml or tool bun.lock files trigger installation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: dca3952f-8c5b-4405-a3eb-8213375249ff

📥 Commits

Reviewing files that changed from the base of the PR and between aa8c7b1 and 02891ee.

📒 Files selected for processing (3)
  • justfile
  • nix/dev-shell.nix
  • nix/git-wt.nix

Comment thread nix/dev-shell.nix
Comment on lines +92 to +100
needsInstall=false
if [ ! -e node_modules/.install-stamp ]; then
needsInstall=true
else
for lock in pnpm-lock.yaml nix/tools/*/bun.lock; do
if [ "$lock" -nt node_modules/.install-stamp ]; then
needsInstall=true
fi
done

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Detect deleted lockfiles, not only newer ones.

The mtime-only check misses deletions: once pnpm-lock.yaml or a tool bun.lock disappears, the glob no longer yields that file, so needsInstall remains false and stale dependencies survive. Store and compare a lockfile path/content fingerprint, or otherwise detect lockfile-set changes.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@nix/dev-shell.nix` around lines 92 - 100, The needsInstall check must detect
deleted lockfiles as well as modified or newer ones. Update the lockfile
tracking logic around the needsInstall initialization and lock iteration to
compare the current lockfile path/content fingerprint against the state recorded
in node_modules/.install-stamp, so additions, deletions, and changes to
pnpm-lock.yaml or tool bun.lock files trigger installation.

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 02891ee6967d
Base SHA: aa8c7b1d6a91

Performance comparison skipped.

Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided.

Base package: aa8c7b1d6a91

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 02891ee6967d
Base SHA: aa8c7b1d6a91

Performance comparison skipped.

Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided.

Base package: aa8c7b1d6a91

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.

2 participants