Skip to content

flake: skip npm ci in default shell when lockfile already installed#176

Merged
thedavidmeister merged 1 commit into
mainfrom
2026-05-19-skip-npm-ci-when-lockfile-unchanged
May 19, 2026
Merged

flake: skip npm ci in default shell when lockfile already installed#176
thedavidmeister merged 1 commit into
mainfrom
2026-05-19-skip-npm-ci-when-lockfile-unchanged

Conversation

@thedavidmeister
Copy link
Copy Markdown
Contributor

@thedavidmeister thedavidmeister commented May 19, 2026

Summary

  • The default devShell ran npm ci --ignore-scripts on every shell entry whenever a package.json was present, wiping and reinstalling node_modules even when it already matched the lockfile. Painful for ad-hoc nix develop -c <cmd> invocations.
  • Compare ./package-lock.json to the copy npm writes into ./node_modules/.package-lock.json after a successful install, and skip npm ci when they match.
  • First entry (or any entry after the lockfile changes) still runs npm ci.

Closes #175

Test plan

  • nix develop in a repo with a package.json + package-lock.json triggers npm ci on first entry, then is a no-op on subsequent entries.
  • After modifying package-lock.json, the next nix develop entry re-runs npm ci.
  • nix develop in a repo without package.json remains a no-op.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Optimized development environment setup to run dependency installation only when necessary, improving development workflow efficiency.

Review Change Stack

The default devShell ran npm ci on every entry whenever package.json was
present, wiping and reinstalling node_modules even when it already matched
the lockfile. Compare ./package-lock.json to the copy npm writes into
./node_modules/.package-lock.json after a successful install, and skip
when they match. First entry (or any entry after the lockfile changes)
still runs npm ci.

Closes #175

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b1844be5-09e5-47f8-84b0-50dc8a62135d

📥 Commits

Reviewing files that changed from the base of the PR and between b947843 and 8904a6e.

📒 Files selected for processing (1)
  • flake.nix

📝 Walkthrough

Walkthrough

The default devShell's shellHook in flake.nix now checks whether package-lock.json matches node_modules/.package-lock.json before running npm ci. This prevents unnecessary dependency reinstalls when the lockfile is already synchronized with the installed tree.

Changes

Dev Shell Optimization

Layer / File(s) Summary
npm ci Guard Condition
flake.nix
The shellHook condition is tightened to check both package.json existence and lockfile synchronization before running npm ci, skipping reinstalls when package-lock.json matches node_modules/.package-lock.json.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A single guard stands tall and wise,
Comparing locks with careful eyes—
No needless npm reinstalls today,
Shell entries faster than yesterday! 🚀

🚥 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 and concisely describes the main change: skipping npm ci when the lockfile is already installed, matching the core objective.
Linked Issues check ✅ Passed The code change directly implements the proposal from issue #175: comparing package-lock.json to node_modules/.package-lock.json to skip npm ci when they match.
Out of Scope Changes check ✅ Passed The change is narrowly scoped to the intended modification of the npm ci condition in flake.nix, with no unrelated alterations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-05-19-skip-npm-ci-when-lockfile-unchanged

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 and usage tips.

@thedavidmeister thedavidmeister merged commit d444279 into main May 19, 2026
13 checks passed
@github-actions
Copy link
Copy Markdown

@coderabbitai assess this PR size classification for the totality of the PR with the following criterias and report it in your comment:

S/M/L PR Classification Guidelines:

This guide helps classify merged pull requests by effort and complexity rather than just line count. The goal is to assess the difficulty and scope of changes after they have been completed.

Small (S)

Characteristics:

  • Simple bug fixes, typos, or minor refactoring
  • Single-purpose changes affecting 1-2 files
  • Documentation updates
  • Configuration tweaks
  • Changes that require minimal context to review

Review Effort: Would have taken 5-10 minutes

Examples:

  • Fix typo in variable name
  • Update README with new instructions
  • Adjust configuration values
  • Simple one-line bug fixes
  • Import statement cleanup

Medium (M)

Characteristics:

  • Feature additions or enhancements
  • Refactoring that touches multiple files but maintains existing behavior
  • Breaking changes with backward compatibility
  • Changes requiring some domain knowledge to review

Review Effort: Would have taken 15-30 minutes

Examples:

  • Add new feature or component
  • Refactor common utility functions
  • Update dependencies with minor breaking changes
  • Add new component with tests
  • Performance optimizations
  • More complex bug fixes

Large (L)

Characteristics:

  • Major feature implementations
  • Breaking changes or API redesigns
  • Complex refactoring across multiple modules
  • New architectural patterns or significant design changes
  • Changes requiring deep context and multiple review rounds

Review Effort: Would have taken 45+ minutes

Examples:

  • Complete new feature with frontend/backend changes
  • Protocol upgrades or breaking changes
  • Major architectural refactoring
  • Framework or technology upgrades

Additional Factors to Consider

When deciding between sizes, also consider:

  • Test coverage impact: More comprehensive test changes lean toward larger classification
  • Risk level: Changes to critical systems bump up a size category
  • Team familiarity: Novel patterns or technologies increase complexity

Notes:

  • the assessment must be for the totality of the PR, that means comparing the base branch to the last commit of the PR
  • the assessment output must be exactly one of: S, M or L (single-line comment) in format of: SIZE={S/M/L}
  • do not include any additional text, only the size classification
  • your assessment comment must not include tips or additional sections
  • do NOT tag me or anyone else on your comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Tip

For best results, initiate chat on the files or code changes.

SIZE=S

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.

default devShell unconditionally runs npm ci on every shell entry

1 participant