Skip to content

ci: regenerate bun.nix automatically - #1909

Merged
ryoppippi merged 3 commits into
mainfrom
cursor/regenerate-bun-nix-automatically-0ca0
Oct 17, 2026
Merged

ryoppippi merged 3 commits into
mainfrom
cursor/regenerate-bun-nix-automatically-0ca0

Conversation

@ryoppippi

@ryoppippi ryoppippi commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Renovate PRs that bump a nix/tools/*/bun.lock leave the sibling bun.nix stale, so the bun-nix flake check fails until someone runs just gen-bun-nix by hand (most recently on #1908).

Approach

The existing autofix.ci workflow now runs nix run .#generate-bun-nix before nix fmt. autofix.ci pushes through its GitHub App, so its commit retriggers CI and no PAT is needed. It runs on every PR, so manifest-only bumps and lockFileMaintenance PRs are covered too. bun2nix only parses the lockfile, so no network access or package installs are involved, and an up-to-date tree produces no diff.

The manually dispatched renovate-bun-nix.yaml workflow is removed. It needed someone to start it, and because it pushed with GITHUB_TOKEN, its commit did not retrigger CI.

Other options I ruled out:

  • Renovate postUpgradeTasks: the hosted app rejects them (see fix(renovate): gate Bun regeneration manually #1747).
  • A separate workflow that commits to Renovate branches: its push would need a PAT or App token to retrigger CI.
  • A treefmt formatter on bun.lock: treefmt-nix excludes *.lock by default, so it never runs.

Testing

  • Reproduced chore(deps): update node.js to >=24.22.0 #1908: on Renovate's commit 775f1dcc, which has the stale bun.nix, nix run .#generate-bun-nix produced a nix/tools tree byte-identical to the hand-made fix 751e20a5. A later nix fmt -- --no-cache changed 0 files.
  • On current main, the generator leaves the tree unchanged, so autofix pushes nothing to unrelated PRs.
  • nix fmt -- --fail-on-change (actionlint, zizmor, nixfmt) passes on the changed files.
  • The autofix job on this PR runs the new step.
Open in Web Open in Cursor 

Summary by cubic

Regenerates bun.nix automatically on dependency PRs so Renovate bumps to bun.lock no longer leave the bun-nix flake check failing until someone runs just gen-bun-nix by hand.

  • The autofix.ci job now runs nix run .#generate-bun-nix before formatting, keeping only changes to nix/tools/*/bun.nix and discarding the rest. A treefmt formatter wouldn't work because treefmt-nix excludes *.lock files by default.
  • Removes the manually dispatched renovate-bun-nix.yaml workflow, which required someone to trigger it and pushed with GITHUB_TOKEN so its commit didn't retrigger CI.

Written for commit 10c39f3. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Chores
    • The automated fix workflow now refreshes Bun-related Nix files before applying formatting and lint fixes, while keeping unrelated changes out of the generated update.
    • The separate workflow for processing Renovate pull requests has been removed. Renovate-related updates are no longer processed through that workflow.

Run the bun.nix generator as a treefmt formatter on nix/tools/*/bun.lock so autofix.ci commits regenerated derivations on dependency PRs, and drop the manually dispatched Renovate workflow it replaces.
@coderabbitai

coderabbitai Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 6bd9c033-ac59-4834-9753-f383014a2bd7
📥 Commits

Reviewing files that changed from the base of the PR and between adc551a and 10c39f3.

📒 Files selected for processing: 1
  • .github/workflows/autofix.yaml

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The autofix workflow now regenerates Bun derivations before formatting and lint fixes. The dedicated Renovate workflow was removed. The generate-bun-nix description now says autofix.ci runs the generator on pull requests.

Changes: Bun derivation generation

Layer / File(s) Summary
Run Bun derivation generation in autofix
.github/workflows/autofix.yaml, .github/workflows/renovate-bun-nix.yaml, nix/treefmt.nix
The autofix workflow runs the generator and removes changes outside nix/tools/*/bun.nix. The dedicated Renovate workflow, including its validation and publish steps, was removed. The app description now states that autofix.ci runs the generator on pull requests.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~15 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 10c39

Renovate lockfile pull requests now regenerate and retain their canonical sibling bun.nix files. No concrete current-head merge risk remains.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: automatic regeneration of bun.nix files in CI.
Docstring Coverage Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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.
Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (1 skipped: 1 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

cloudflare-workers-and-pages Bot commented Oct 17, 2026 •

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 10c39f3 Commit Preview URL

Branch Preview URL
Oct 17 2026, 12:31 PM

@pkg-pr-new

pkg-pr-new Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

ccusage

npx https://pkg.pr.new/ccusage@1909

@ccusage/ccusage-darwin-arm64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-arm64@1909

@ccusage/ccusage-darwin-x64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-x64@1909

@ccusage/ccusage-linux-arm64

npx https://pkg.pr.new/@ccusage/ccusage-linux-arm64@1909

@ccusage/ccusage-linux-x64

npx https://pkg.pr.new/@ccusage/ccusage-linux-x64@1909

@ccusage/ccusage-win32-x64

npx https://pkg.pr.new/@ccusage/ccusage-win32-x64@1909

commit: 10c39f3

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: ec6fb19783b0
Base SHA: 69236a2d60d7

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: 69236a2d60d7

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: ec6fb19783b0
Base SHA: 69236a2d60d7

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: 69236a2d60d7

treefmt-nix excludes *.lock by default, so a bun.lock formatter never runs. Call generate-bun-nix directly in the autofix.ci job instead.
@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: adc551a79019
Base SHA: 69236a2d60d7

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: 69236a2d60d7

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: adc551a79019
Base SHA: 69236a2d60d7

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: 69236a2d60d7

@ryoppippi
ryoppippi marked this pull request as ready for review October 17, 2026 11:03

@pullfrog pullfrog Bot 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.

✅ No new issues found — standing instructions prevent formal approval, so this is a comment-only review with no requested changes.

Reviewed changes covered the full diff on PR #1909 (autofix-driven bun.nix regeneration).

  • Autofix generates Bun derivations: autofix.yaml runs nix run .#generate-bun-nix before nix fmt, so Renovate bun.lock bumps get a matching bun.nix without a hand run.
  • Manual Renovate workflow removed: the 222-line renovate-bun-nix.yaml dispatch/inspect/generate/publish chain is deleted with no remaining repo references.
  • Generator comment updated: nix/treefmt.nix now documents autofix.ci as the automatic caller instead of Renovate.

Pullfrog  | Fix it ➔ | View workflow run | Using muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏

@cubic-dev-ai cubic-dev-ai Bot 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.

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name=".github/workflows/autofix.yaml">

<violation number="1" location=".github/workflows/autofix.yaml:28">
P1: This executes the pull request’s flake as the Bun generator, so a PR can replace `generateBunNix` or make it modify arbitrary files that the following autofix step publishes. Run the generator from a trusted base revision, then validate and stage only `nix/tools/*/bun.nix` before pushing.

(Based on your team's feedback about validating generated Bun derivation paths and staging the allowed patch.) [7e0a998c-14aa-42d6-8b21-92e4ce083220]</violation>
</file>

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .github/workflows/autofix.yaml Outdated
with:
disk-job: preflight
- name: Regenerate Bun derivations
run: nix run .#generate-bun-nix

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.

P1: This executes the pull request’s flake as the Bun generator, so a PR can replace generateBunNix or make it modify arbitrary files that the following autofix step publishes. Run the generator from a trusted base revision, then validate and stage only nix/tools/*/bun.nix before pushing.

(Based on your team's feedback about validating generated Bun derivation paths and staging the allowed patch.) [7e0a998c-14aa-42d6-8b21-92e4ce083220]

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/workflows/autofix.yaml, line 28:

<comment>This executes the pull request’s flake as the Bun generator, so a PR can replace `generateBunNix` or make it modify arbitrary files that the following autofix step publishes. Run the generator from a trusted base revision, then validate and stage only `nix/tools/*/bun.nix` before pushing.

(Based on your team's feedback about validating generated Bun derivation paths and staging the allowed patch.) [7e0a998c-14aa-42d6-8b21-92e4ce083220]</comment>

<file context>
@@ -24,6 +24,8 @@ jobs:
         with:
           disk-job: preflight
+      - name: Regenerate Bun derivations
+        run: nix run .#generate-bun-nix
       - name: Apply formatting and lint fixes
         run: |
</file context>

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@cubic-dev-ai Hardened in 10c39f3. After the generator runs, the step now discards every staged, modified, or untracked change outside nix/tools/*/bun.nix (git restore --staged --worktree plus git clean, both scoped with an exclude pathspec), so that step can only contribute bun.nix changes to the fix.

I kept the generator on the PR's flake rather than the base revision. The next step already runs nix fmt from the same PR flake, so pinning just this generator wouldn't change the trust boundary. Running the PR's own generator also lets PRs that change the generator get tested. autofix.ci runs with a read-only token, and PRs here are collaborator-gated.

@pullfrog pullfrog Bot 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.

✅ No new issues found — the new commit scopes the generator's file writes to bun.nix only.

Reviewed changes reviewed the single new commit since the prior Pullfrog review.

  • Constrained generator output to bun.nix: the Regenerate Bun derivations step now restores tracked changes and cleans untracked files everywhere except nix/tools/*/bun.nix, so only bun.nix updates reach nix fmt and the autofix push.

Pullfrog  | Fix it ➔ | View workflow run | Using muse-spark-1.3-contributor (free via Pullfrog for OSS) | 𝕏

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 10c39f3d987a
Base SHA: 69236a2d60d7

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: 69236a2d60d7

@github-actions

Copy link
Copy Markdown
Contributor

ccusage performance comparison

PR SHA: 10c39f3d987a
Base SHA: 69236a2d60d7

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: 69236a2d60d7

@ryoppippi
ryoppippi merged commit 130e502 into main Oct 17, 2026
48 checks passed
@ryoppippi
ryoppippi deleted the cursor/regenerate-bun-nix-automatically-0ca0 branch October 17, 2026 12:42
Buster210 added a commit to Buster210/ccusage that referenced this pull request Oct 20, 2026
Upstream tip: c76874e (2026-10-20, chore(pricing): update models.dev snapshot)
Previous fork base: 0c58b88 (the upstream commit this fork was synced to)

Synced 83 upstream commits on top of 0c58b88: 56 automated pricing
snapshot refreshes and the following meaningful ones:

  1cd29f5 chore(deps): update pnpm to v12.13.0 (ccusage#1907)
  e4f63ba chore(deps): update node.js to >=24.22.0 (ccusage#1908)
  130e502 ci: regenerate bun.nix automatically (ccusage#1909)
  259ec33 feat(adapter): report stored cost in JSON model breakdowns (ccusage#1903)
  c1eb448 chore: release v20.0.35 (ccusage#1901)
  2a0875f ci(pricing): update snapshots on push to main and daily instead of hourly (ccusage#1914)
  b090428 chore(deps): update github/codeql-action action to v4.39.0 (ccusage#1912)
  4dcf7f5 fix(nix): pin models-dev-gen remeda to models.dev's version and stop Renovate drift (ccusage#1915)
  46edb28 fix(nix): stop the dev shell from copying the whole repository (ccusage#1917)
  58ec8f1 fix(nix): let commits succeed in worktrees without a loaded dev shell (ccusage#1920)
  a570a6f fix(nix): vendor Cargo deps without import-from-derivation (ccusage#1918)
  f6d28c5 fix(antigravity): map model IDs 1418/1419 to gemini-4-argon (ccusage#1905)
  ce439e5 fix(antigravity): map model ID 1050 to gemini-3.1-flash-lite (ccusage#1902)
  e62a66f chore(deps): update pnpm to v12.14.0 (ccusage#1923)
  117ae68 ci(nix): make the macOS Nix cache save a trimmed store with the Crane layers (ccusage#1921)
  7a063a0 ci: shorten the Windows native build critical path (ccusage#1924)
  85ebca3 perf(rust): move pricing snapshots into a leaf crate (ccusage#1922)
  8fe3f47 perf(nix): build Crane layers with the binary's feature resolution (ccusage#1925)
  ac289aa perf(pricing): give the pricing refresh a verify-only TLS 1.3 rustls provider (ccusage#1927)
  d097f74 chore(deps): update rust crate rustls to 0.23.46 (ccusage#1928)
  f8aaf89 docs: use the compact pkg.pr.new URL for bunx previews [ci skip] (ccusage#1929)
  f56bb3d chore: release v20.0.36 (ccusage#1916)
  aaafb41 chore(deps): update dependency vitepress-plugin-group-icons to ^1.8.1 (ccusage#1931)
  0861e7f fix(claude): count requestless resp_ content blocks once (ccusage#1935)
  867c9f3 chore: release v20.0.37 (ccusage#1933)
  fa40bfd chore(deps): update songmu/tagpr action to v1.21.3 (ccusage#1937)
  de99d15 chore(deps): update rust crate zstd to 0.14.3 (ccusage#1936)

Fork wins kept: the SQLite on-disk cache with --live-only and the per-namespace
ledger, the pi adapter and its per-path namespaces, the OpenCode V2 loader, the
FxHash/Cow hot paths, the table renderer, clear-cache, and the tag-only release
workflow. Upstream's own release and tagpr machinery stays out.

Hand-resolved conflicts:

  rust/adapters/claude/src/lib.rs: upstream's resp_ message-id dedupe (ccusage#1935) lands
    beside the fork's requestless replay and collapse_replays rules.
  rust/adapters/claude/src/README.md: upstream's wording for the msg_/resp_ exception.
  rust/Cargo.toml: zstd 0.14.3, keeping the fork's exact `=` pin style.
  .github/workflows/release.yaml: the fork's tag-only release, without upstream's
    tagpr job or the songmu/tagpr action bump.
  apps/ccusage/package.json, docs/package.json, package.json: keep 20.0.34;
    upstream's 20.0.37 bump is dropped.
  packages/ccusage-*/package.json (6 files): stay deleted; the fork ships no npm
    wrapper packages and the release workflow does not read them.
  rust/adapters/claude/src/daily.rs: stays deleted; the fork's daily path lives in
    lib.rs and shares the dedupe helper the fix changes.

Fixes made while landing this sync, folded in so the merge stands green on its own:

  fix(ci): save the Nix store from the native build composites. The nested
    cache-nix-action read an empty primary-key at post-job and every native
    build failed; upstream's defer-save pattern is the fix.
  fix(rust): keep the agent-recorded cost for deleted sources. The recorded_cost
    ledger column carries it, so storedCost survives a deleted file. The ledger
    schema version stays at 2: the column is not a LedgerEntry field, so the blob
    layout is unchanged and the previously released binary keeps working.
  fix(rust): make the file fingerprint helper private, the one hawk finding. It is
    inherited from the pre-sync master, not introduced here.

Keep 20.0.34 numbering; DO NOT push a v20.0.34 tag from this fork (release.yaml
would publish fork bytes under upstream identity).
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