Skip to content

feat(ci): add Nix flake and manual nightly builds#19

Open
zortos293 wants to merge 2 commits into
mainfrom
capy/nix-flake-nightly
Open

feat(ci): add Nix flake and manual nightly builds#19
zortos293 wants to merge 2 commits into
mainfrom
capy/nix-flake-nightly

Conversation

@zortos293

@zortos293 zortos293 commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

This PR adds Nix flake support for reproducible development environments and a manually triggered nightly build workflow.

Changes

  • flake.nix: Add Nix flake with dev shell (bun, nodejs, electron on Linux), dev app, and alejandra formatter
  • tools/fix-electron-install.cjs: Skip Electron binary download when ELECTRON_SKIP_BINARY_DOWNLOAD or npm_config_electron_skip_binary_download is set for use with Nix-provided Electron
  • .github/workflows/nightly.yml: Add manually triggered nightly build workflow supporting Windows, macOS, and Linux (x64/arm64) with artifact uploads

Run nix develop to enter the dev shell or trigger the nightly workflow from GitHub Actions.

Open OPE-016 OPE-016


Note

Low Risk
CI and local-dev tooling only; no runtime app logic changes beyond optional Electron install behavior when env vars are set.

Overview
Adds Nix (flake.nix + flake.lock) for reproducible dev on Linux/macOS: default dev shell with bun, Node 22, Linux packaging tools, and on Linux Nix-provided Electron via ELECTRON_SKIP_BINARY_DOWNLOAD / ELECTRON_OVERRIDE_DIST_PATH. Also exposes nix run dev app and an alejandra formatter.

tools/fix-electron-install.cjs now exits early when those skip-download env vars are set, so npm install does not fetch Electron binaries in the Nix shell.

New .github/workflows/nightly.yml: workflow_dispatch on a chosen branch; preflight validates the branch, computes YYYYMMDD.runNumber nightly id and base-nightly.* version; matrix build on Blacksmith runners for Windows/macOS/Linux x64 and arm64, bumps version with sync-release-version.mjs, builds and packages with electron-builder (no publish), uploads per-platform artifacts.

Reviewed by Cursor Bugbot for commit 1558bcd. Configure here.

Summary by CodeRabbit

  • New Features
    • Added a manually-triggered nightly build workflow that packages for multiple desktop platforms and architectures.
    • Introduced a Nix flake with per-system development shells, a default dev app, and a formatting utility.
  • Bug Fixes
    • Improved Electron installation behavior to respect truthy “skip binary download” environment settings and avoid unnecessary Electron binary fetching.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@zortos293 zortos293 added the capy Generated by capy.ai label Jul 5, 2026 — with Capy AI
@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 1440de22-4b23-47b3-8017-25b54fb7ac30

📥 Commits

Reviewing files that changed from the base of the PR and between 1558bcd and 1fc902c.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (2)
  • .github/workflows/nightly.yml
  • flake.nix
🚧 Files skipped from review as they are similar to previous changes (2)
  • flake.nix
  • .github/workflows/nightly.yml

📝 Walkthrough

Walkthrough

This PR adds a nightly GitHub Actions workflow for branch-scoped Electron packaging, a Nix flake for development and formatting, and an Electron install script guard that skips binary download when configured.

Changes

Nightly build automation

Layer / File(s) Summary
Workflow trigger and preflight metadata
.github/workflows/nightly.yml
Adds the manual nightly trigger, concurrency, permissions, branch validation, checkout, Node setup, and nightly metadata outputs.
Build matrix and packaging steps
.github/workflows/nightly.yml
Adds the multi-platform build matrix, cache and environment setup, Linux packaging prerequisites, nightly version sync, packaging, and artifact upload steps.

Nix dev environment and Electron install guard

Layer / File(s) Summary
Flake devShells, apps, and formatter
flake.nix
Defines per-system dev shells, a dev app, and a formatter app with Linux-specific Electron environment setup.
Electron install skip-download guard
tools/fix-electron-install.cjs
Adds truthy env parsing and exits early when Electron binary download is disabled by environment variables.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

🚥 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 changes: adding a Nix flake and a manually triggered nightly build workflow.
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 capy/nix-flake-nightly

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

@cursor cursor 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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 1558bcd. Configure here.

ELECTRON_BUILDER_CACHE: ${{ github.workspace }}/.cache/electron-builder
NIGHTLY_VERSION: ${{ needs.preflight.outputs.nightly_version }}
npm_config_audit: "false"
npm_config_fund: "false"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing USE_SYSTEM_FPM arm64

Medium Severity

The nightly build job installs system fpm on the linux-arm64 matrix row but never sets USE_SYSTEM_FPM, unlike the existing release workflow. electron-builder then tends to use its bundled x86 fpm on ARM runners, so Linux arm64 .deb packaging in nightly can fail even after the gem install step.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 1558bcd. Configure here.

@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: 2

🧹 Nitpick comments (2)
.github/workflows/nightly.yml (1)

20-29: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Consider adding timeout-minutes to jobs.

Neither preflight nor build specifies a timeout. Since build spans six platform/arch combinations with native packaging tools (fpm, electron-builder, gem installs), a hang in any leg would consume runner minutes indefinitely with cancel-in-progress: false.

♻️ Suggested addition
   preflight:
     name: preflight
     runs-on: blacksmith-2vcpu-ubuntu-2404
+    timeout-minutes: 15
   build:
     name: ${{ matrix.label }}
     runs-on: ${{ matrix.os }}
     needs: preflight
+    timeout-minutes: 45

Also applies to: 77-134

🤖 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 @.github/workflows/nightly.yml around lines 20 - 29, Add explicit timeout
limits to the workflow jobs that currently omit them, especially the preflight
and build jobs. Update the job definitions in the nightly workflow so each job
has a reasonable timeout-minutes value, using the existing job names and the
build matrix job as the main targets. This keeps hung runs from consuming runner
minutes indefinitely while preserving the current job structure and outputs.
flake.nix (1)

37-46: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicated Linux Electron env-var block between devShell and app.

The three ELECTRON_SKIP_BINARY_DOWNLOAD/ELECTRON_OVERRIDE_DIST_PATH/npm_config_electron_skip_binary_download exports are duplicated verbatim between the devShells.default shellHook and openstroidDev's text. Consider factoring into a shared let-bound string to keep both in sync going forward.

♻️ Example refactor
     devShells = forAllSystems (system: let
       pkgs = pkgsFor system;
+      linuxElectronEnv = ''
+        export ELECTRON_SKIP_BINARY_DOWNLOAD=1
+        export ELECTRON_OVERRIDE_DIST_PATH="${pkgs.electron}/bin"
+        export npm_config_electron_skip_binary_download=true
+      '';
     in {
       default = pkgs.mkShell {
         ...
         shellHook =
           ''
             export ELECTRON_CACHE="$PWD/.cache/electron"
             export ELECTRON_BUILDER_CACHE="$PWD/.cache/electron-builder"
           ''
-          + pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux ''
-            export ELECTRON_SKIP_BINARY_DOWNLOAD=1
-            export ELECTRON_OVERRIDE_DIST_PATH="${pkgs.electron}/bin"
-            export npm_config_electron_skip_binary_download=true
-          '';
+          + pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux linuxElectronEnv;
       };
     });

Also applies to: 60-68

🤖 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 `@flake.nix` around lines 37 - 46, The Linux Electron environment-variable
exports are duplicated between the dev shell hook and the app wrapper text, so
factor the shared block into a single let-bound string and reuse it in both
places. Update the shellHook in the devShells.default section and the
openstroidDev definition to reference the same shared snippet for the
ELECTRON_SKIP_BINARY_DOWNLOAD, ELECTRON_OVERRIDE_DIST_PATH, and
npm_config_electron_skip_binary_download exports, keeping the Linux-only
conditional in one place.
🤖 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 @.github/workflows/nightly.yml:
- Around line 48-51: Set persist-credentials to false on both actions/checkout
steps so the GITHUB_TOKEN is not left in the local git config during the job.
Update the checkout invocations in the nightly workflow, including the Checkout
source branch step and the other checkout occurrence referenced by the review,
to explicitly disable credential persistence while keeping the existing ref
behavior intact.

In `@flake.nix`:
- Around line 30-35: The Linux dev shell in flake.nix is pulling in nixpkgs’
rolling electron, which can override the app’s pinned Electron major and create
a runtime version mismatch. Update the Linux package list used by the dev
shell/openstroid-dev wrapper so Electron matches the version pinned in
package.json (37.x), or remove the Electron override entirely; use the electron
identifier in the flake output to locate the change.

---

Nitpick comments:
In @.github/workflows/nightly.yml:
- Around line 20-29: Add explicit timeout limits to the workflow jobs that
currently omit them, especially the preflight and build jobs. Update the job
definitions in the nightly workflow so each job has a reasonable timeout-minutes
value, using the existing job names and the build matrix job as the main
targets. This keeps hung runs from consuming runner minutes indefinitely while
preserving the current job structure and outputs.

In `@flake.nix`:
- Around line 37-46: The Linux Electron environment-variable exports are
duplicated between the dev shell hook and the app wrapper text, so factor the
shared block into a single let-bound string and reuse it in both places. Update
the shellHook in the devShells.default section and the openstroidDev definition
to reference the same shared snippet for the ELECTRON_SKIP_BINARY_DOWNLOAD,
ELECTRON_OVERRIDE_DIST_PATH, and npm_config_electron_skip_binary_download
exports, keeping the Linux-only conditional in one place.
🪄 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: f0aca7e6-84a2-488f-ad93-3d5495f95b73

📥 Commits

Reviewing files that changed from the base of the PR and between 51426a2 and 1558bcd.

⛔ Files ignored due to path filters (1)
  • flake.lock is excluded by !**/*.lock
📒 Files selected for processing (3)
  • .github/workflows/nightly.yml
  • flake.nix
  • tools/fix-electron-install.cjs

Comment thread .github/workflows/nightly.yml
Comment thread flake.nix
Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant