Skip to content

ci: auto-sync bun.nix when a PR changes bun.lock - #79

Merged
loss-and-quick merged 1 commit into
mainfrom
ci/auto-sync-bun-nix
Jun 22, 2026
Merged

ci: auto-sync bun.nix when a PR changes bun.lock#79
loss-and-quick merged 1 commit into
mainfrom
ci/auto-sync-bun-nix

Conversation

@loss-and-quick

Copy link
Copy Markdown
Owner

Summary

bun.nix is the generated Nix mirror of bun.lock (the flake's frontend build reconstructs node_modules from it via bun2nix.fetchBunDeps, see nix/desktop.nix). A contributor who isn't on Nix — or who just forgets to run bunx bun2nix — can land a bun.lock change with a stale bun.nix and break the nix build (exactly what happened in #77 until it was caught manually).

New workflow .github/workflows/sync-bun-nix.yml:

  • Trigger — only PRs that touch bun.lock (first "is it needed" gate).
  • Regeneratebunx bun2nix@2.1.0 (pinned to the version flake.nix locks, so the output format always matches fetchBunDeps).
  • Commit only if it actually driftedgit diff --quiet -- bun.nix; if the file is already in sync (author ran bun2nix themselves, or the lock change didn't affect the Nix output) it does nothing (second gate). Otherwise it pushes one chore(nix): sync bun.nix with bun.lock commit onto the PR branch.

Affected layer

  • frontend/ — React Web UI
  • crates/ · src-tauri/ — Rust core / backend / Tauri desktop
  • module/ — Android installable zip (thin launcher over the Rust daemon)
  • scripts/ — build / release helpers
  • CI / .github/
  • Docs only

Verification

  • actionlint 1.7.12 clean on the new workflow (same version lint-workflows.yml pins)
  • bunx bun2nix@2.1.0 --output-file bun.nix reproduces the committed file locally (verified while preparing feat(profiles): reorder groups via drag-and-drop #77)
  • Reused the exact pinned action SHAs already in ci.yml (actions/checkout v4, oven-sh/setup-bun v2).

Checklist

  • Title is a scoped Conventional Commit
  • No build artifacts committed
  • Third-party actions pinned to commit SHAs with a version comment

Notes for reviewers

  • Loop safety: the commit is pushed with the default GITHUB_TOKEN, and GitHub does not trigger workflows from GITHUB_TOKEN pushes — so the bot commit cannot re-trigger this (or any) workflow. The git diff --quiet gate is a second guard regardless.
  • Forks: GITHUB_TOKEN is read-only for fork PRs, so pushing back is impossible there. The job is if-guarded to same-repo PRs; on forks the regular nix build still fails loudly on drift, prompting the author to run bunx bun2nix. (A fork-friendly variant would post a comment instead — happy to add if wanted.)
  • CI re-run: because the bot push uses GITHUB_TOKEN, other checks won't auto re-run on the sync commit. That's the deliberate trade-off for loop safety (a PAT would re-run CI but reintroduce loop risk and token management).
  • Keep in lockstep: if flake.nix bumps the bun2nix ref, bump the bunx bun2nix@<ver> pin in this workflow too (noted in an inline comment).

bun.nix is generated from bun.lock (bun2nix) and consumed by the flake's
frontend build. Contributors not on Nix — or who forget `bunx bun2nix` —
would land a bun.lock change with a stale bun.nix and break the nix build.

New workflow regenerates bun.nix on PRs that touch bun.lock and pushes a
chore commit ONLY when the result actually differs from what's committed
(regenerate → `git diff --quiet -- bun.nix` → no drift, no commit). Guarded
to same-repo PRs (fork GITHUB_TOKEN can't push back); bun2nix pinned to the
flake's 2.1.0 so the output format always matches fetchBunDeps.
@github-actions github-actions Bot added the ci CI / workflows (.github/) label Jun 21, 2026
@loss-and-quick
loss-and-quick merged commit 7c602ba into main Jun 22, 2026
8 checks passed
@loss-and-quick
loss-and-quick deleted the ci/auto-sync-bun-nix branch June 22, 2026 00:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci CI / workflows (.github/)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant