Skip to content

ci: add nix flake check and build job - #405

Merged
LargeModGames merged 2 commits into
mainfrom
ci/nix-flake-check
Jul 26, 2026
Merged

ci: add nix flake check and build job#405
LargeModGames merged 2 commits into
mainfrom
ci/nix-flake-check

Conversation

@LargeModGames

@LargeModGames LargeModGames commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Summary

Adds a Nix leg that the Rust matrix cannot cover. Three steps, cheapest first:

  • nix flake check --all-systems --no-build catches outputs declared under the wrong attribute path. This is the fix: nix develop flake output #401 class of bug: devShells and apps nested inside packages evaluated fine but were invisible to Nix, so nix run had no target and nix develop silently fell back to the package derivation. That had been the case since v0.37.0.
  • nix develop --command cargo --version guards the dev shell directly: reachable, and actually carrying the toolchain.
  • nix build --no-link .#default catches drift between the librespot-* entries in cargoLock.outputHashes and the fork rev in Cargo.toml's [patch] block. Nothing links the two, so bumping the fork without regenerating the hash breaks nix build for every Nix user, with a fixed-output hash mismatch that never names the rev. Only an actual build realizes the vendor derivation, so only a build catches it.

Separate workflow rather than a job in ci.yml because GitHub filters paths: at the workflow level only, and the build step compiles the full default feature set.

Testing

Nix is not installed on my machine, so none of the three steps ran locally. The workflow triggers on changes to itself, so this PR's own run is the real verification.

  • python3 -c "import yaml; yaml.safe_load(open('.github/workflows/nix.yml'))" parses clean
  • git ls-files flake.lock confirms the lock is tracked, so the job will not go red merely because nixos-unstable moved
  • gh api repos/cachix/install-nix-action/tags to pin v31.11.0; that repo publishes no moving major tag

Additional notes

  • Not suitable as a required check. With paths: filters it does not run on most PRs, and a required check that never runs leaves them blocked pending forever.
  • Expect the build step to run long whenever it fires. A hermetic nix build gets no benefit from the existing Swatinem/rust-cache. That is inherent to catching hash drift by building; the path filter is the mitigation.
  • If step 1 fails on a darwin attribute rather than on output layout, drop --all-systems. It cross-evaluates the darwin outputs (including pkgs.apple-sdk) from a Linux runner, and the layout bug it guards reproduces on the Linux system alone.

Summary by CodeRabbit

  • Tests
    • Added a Nix-based CI workflow that runs on relevant changes to Nix/Rust or the workflow itself, and on pushes to the main branch.
    • Validates the Nix flake across all systems (without building) and confirms the development shell provides Rust tooling.
    • Builds the flake’s default output and includes protections like limited permissions, a 60-minute timeout, and support for [skip ci].

Guards two failure modes the Rust matrix cannot see. Flake outputs declared
under the wrong attribute path evaluate fine but are invisible to Nix, which is
how devShells and apps stayed nested inside packages since v0.37.0. And the
librespot outputHashes in flake.nix pin the content of the spotatui-librespot
checkout while the rev they match lives in Cargo.toml's [patch] block, so a fork
bump without a regenerated hash breaks nix build with a hash mismatch that never
names the rev.

Path filtered to flake.nix, flake.lock, Cargo.toml and Cargo.lock, since the
build step compiles the full default feature set.
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f01c5e33-5257-4a73-bff8-c10903c86d26

📥 Commits

Reviewing files that changed from the base of the PR and between 9e05506 and 7acf551.

📒 Files selected for processing (1)
  • .github/workflows/nix.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/nix.yml

📝 Walkthrough

Walkthrough

Adds a path-filtered GitHub Actions workflow that installs Nix, evaluates flake outputs, verifies the Rust development shell, and builds the default flake output.

Changes

Nix CI validation

Layer / File(s) Summary
Nix workflow checks
.github/workflows/nix.yml
Runs Nix flake evaluation, verifies Cargo availability in the development shell, and builds the default output on relevant pushes and pull requests.

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

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title uses the required conventional-commit prefix and clearly matches the Nix CI workflow addition.
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 ci/nix-flake-check
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch ci/nix-flake-check

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

@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: 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 @.github/workflows/nix.yml:
- Around line 36-37: Update the workflow steps for actions/checkout and
cachix/install-nix-action to reference immutable full commit SHAs instead of
master or a version tag, and add persist-credentials: false to the checkout
configuration.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: d02f11c0-849a-4b54-8619-f7c5caeb0192

📥 Commits

Reviewing files that changed from the base of the PR and between 761da58 and 9e05506.

📒 Files selected for processing (1)
  • .github/workflows/nix.yml

Comment thread .github/workflows/nix.yml Outdated
Tags and branches are mutable, and this job runs nix build, so a retargeted
action would execute arbitrary code against the build. Dependabot already covers
the github-actions ecosystem and reads the trailing version comment, so these
still get update PRs. Also drops the persisted GITHUB_TOKEN from the local git
config, since the job only reads the repo.
@LargeModGames
LargeModGames merged commit 0d9dc79 into main Jul 26, 2026
17 checks passed
@LargeModGames
LargeModGames deleted the ci/nix-flake-check branch July 26, 2026 10:20
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.

1 participant