refactor(nix): split out the git wt module and auto-install JS deps on shell entry - #1543
Conversation
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.
|
📝 WalkthroughWalkthroughThe dev shell now detects stale JavaScript dependencies using an installation stamp and configures ChangesDev shell dependency and worktree automation
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
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Deploying with
|
| 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 |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
justfilenix/dev-shell.nixnix/git-wt.nix
| 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 |
There was a problem hiding this comment.
🗄️ 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.
ccusage performance comparisonPR SHA: 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: |
ccusage performance comparisonPR SHA: 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: |

Summary
Two dev-shell changes. First, the
git wtrepo config moves out ofnix/dev-shell.nixinto its ownnix/git-wt.nixmodule, matching the layoutrorkai/rork-localalready uses. Second, the dev shell now installs JS dependencies itself when a lockfile is newer than the last install.What Changed
nix/git-wt.nix: takespkgsand aninstallCommand(defaultjust install) and returns thewt.hook/wt.remover/wt.deletehookshellHook fragment. The expanded hook is byte-identical to before.nix/dev-shell.nix: imports that module and appends it toshellHook; adds a guarded auto-install ahead of the agent-skill sync.justfile:just installnow writesnode_modules/.install-stamp, which is what the dev shell checks.Why
Entering the shell after a
git pullthat bumped a lockfile left a stalenode_modulesuntil someone remembered to runjust install— usually surfacing as a confusing type or resolution error rather than as a missing dependency.The stamp file, rather than the
node_modulesmtimes, 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. Becausejust installowns the stamp, thegit wtworktree 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.envrcalready watches the wholenix/tree.Testing
nix fmt— no changesnix eval .#devShells.aarch64-darwin.default.shellHook— thegit wtconfig expands identically to the pre-refactor shellHooktouch nix/tools/publint/bun.lock→ direnv re-enters and installs, then settles back to skippingNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is enabled.Summary by cubic
Split the
git wtworktree wiring into its own Nix module and added auto-install of JS dependencies on dev shell entry when lockfiles change. This prevents stalenode_modulesafter pulls and keeps the shell hook easier to read.Refactors
git wtwiring tonix/git-wt.nix; imported fromnix/dev-shell.nix. The module accepts aninstallCommand(defaultjust install) and emits the samewt.hook/remover/deletehookas before.New Features
node_modules/.install-stamp.just installnow writes the stamp and coverspnpm-lock.yamlandnix/tools/*/bun.lock.Written for commit 02891ee. Summary will update on new commits.
Summary by CodeRabbit
New Features
Improvements