fix(makefile): honor detected NixOS host in CI builds - #2105
Conversation
The CI branches of nix-build and nix-switch hardcoded the 'runner' host for nixosConfigurations, ignoring both HOST and DETECTED_HOST. Framework 13 DMI detection added in #2100 therefore never took effect under CI, failing the make_build_host_resolution shellspec cases on main. Both branches now resolve HOST, then DETECTED_HOST, and fall back to the existing runner path when neither is set.
|
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
You do not have enough credits to review this pull request. Please purchase more credits to continue. |
|
Warning Review limit reached
Next review available in: 53 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Code Review
This pull request updates the Makefile to support building and switching NixOS configurations for specific named (HOST) or auto-detected (DETECTED_HOST) hosts. The review feedback points out an inconsistency in the build commands where sudo and nixos-rebuild are unnecessarily used for building, which can cause permission issues and overhead in CI. It is recommended to use nix build directly, matching the existing fallback and Darwin branches.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if [ -n "$(HOST)" ]; then \ | ||
| echo "Building named NixOS host: $(HOST)"; \ | ||
| $(SUDO) env HOST=$(HOST) HOSTNAME=$(HOST) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) nixpkgs#nixos-rebuild -- build --flake .#$(HOST) --impure; \ | ||
| elif [ -n "$(DETECTED_HOST)" ]; then \ | ||
| echo "Auto-detected host: $(DETECTED_HOST)"; \ | ||
| $(SUDO) env HOST=$(DETECTED_HOST) HOSTNAME=$(DETECTED_HOST) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) nixpkgs#nixos-rebuild -- build --flake .#$(DETECTED_HOST) --impure; \ | ||
| else \ | ||
| HOST=runner HOSTNAME=runner $(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.runner.config.system.build.toplevel $(NIX_FLAGS) --impure --no-update-lock-file --show-trace; \ | ||
| fi; \ |
There was a problem hiding this comment.
Inconsistency in CI NixOS Build Commands
There is a significant inconsistency in how NixOS configurations are built in CI:
- The Darwin CI branch (lines 528-545) and the Linux CI fallback branch (line 554) both use
nix build .#nixosConfigurations.<host>.config.system.build.topleveldirectly withoutsudoornixos-rebuild. - However, the newly added named and auto-detected host branches on Linux CI (lines 549 and 552) use
$(SUDO) ... nixos-rebuild -- buildvianix run nixpkgs#nixos-rebuild.
Using sudo and nixos-rebuild in CI for building (not switching) is problematic because:
- Unnecessary Privileges: Building a Nix derivation does not require root privileges. Running build commands with
sudocan cause permission issues in the workspace or build cache (e.g., root-owned files). - Overhead: Running
nix run nixpkgs#nixos-rebuilddownloads and evaluatesnixos-rebuildfromnixpkgs, adding unnecessary network dependency and overhead in CI.
Recommendation
Use nix build directly, matching the fallback and Darwin branches.
Note: Since the spec test spec/make_build_host_resolution_spec.sh (not in this diff) asserts on --flake .#matic, you will need to update it to expect .#nixosConfigurations.matic.config.system.build.toplevel instead.
if [ -n "$(HOST)" ]; then \
echo "Building named NixOS host: $(HOST)"; \
HOST=$(HOST) HOSTNAME=$(HOST) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.$(HOST).config.system.build.toplevel $(NIX_FLAGS) --impure --no-update-lock-file --show-trace; \
elif [ -n "$(DETECTED_HOST)" ]; then \
echo "Auto-detected host: $(DETECTED_HOST)"; \
HOST=$(DETECTED_HOST) HOSTNAME=$(DETECTED_HOST) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.$(DETECTED_HOST).config.system.build.toplevel $(NIX_FLAGS) --impure --no-update-lock-file --show-trace; \
else \
HOST=runner HOSTNAME=runner $(NIX_ALLOW_UNFREE) $(NIX_EXEC) build .#nixosConfigurations.runner.config.system.build.toplevel $(NIX_FLAGS) --impure --no-update-lock-file --show-trace; \
fi; \
| $(SUDO) env HOST=$(HOST) HOSTNAME=$(HOST) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) --impure nixpkgs#nixos-rebuild -- switch --flake .#$(HOST) --no-update-lock-file || exit 0; \ | ||
| elif [ -n "$(DETECTED_HOST)" ]; then \ | ||
| echo "Auto-detected host: $(DETECTED_HOST)"; \ | ||
| $(SUDO) env HOST=$(DETECTED_HOST) HOSTNAME=$(DETECTED_HOST) $(NIX_ALLOW_UNFREE) $(NIX_EXEC) run $(NIX_FLAGS) --impure nixpkgs#nixos-rebuild -- switch --flake .#$(DETECTED_HOST) --no-update-lock-file || exit 0; \ |
There was a problem hiding this comment.
Silent failure masking on real hosts in CI switch: The || exit 0 here is copied from the runner fallback (which needs it because CI runners aren't NixOS), but applying it to the HOST and DETECTED_HOST arms means a genuine nixos-rebuild switch failure on a named host will be swallowed and the Make recipe will still succeed. The non-CI equivalents at Makefile:743-748 deliberately don't do this. Not reachable today because ubuntu-latest can't switch NixOS anyway, but it becomes a real problem the moment a self-hosted NixOS runner (e.g., the Framework 13 matic machine this PR is enabling) runs make nix-switch. Consider dropping || exit 0 from the two HOST/DETECTED_HOST arms and keeping it only on the runner fallback.
Mesa DescriptionTL;DRHonors the detected NixOS host configuration during CI builds, resolving shellspec workflow failures on What changed?
Description generated by Mesa. Update settings |
Problem
The
Shellworkflow is failing onmain. Two shellspec cases inspec/make_build_host_resolution_spec.shfail:detects matic from Framework 13 AMD AI 300 DMI data when the hostname is genericswitches the detected matic host through the generic NixOS pathThe CI branches of
nix-buildandnix-switchhardcoded therunnerhost fornixosConfigurations, ignoring bothHOSTandDETECTED_HOST. The Framework 13 DMI detection added in #2100 only wired into the non-CI branches, so it never took effect whenCI=true. The specs run in CI, hit the hardcoded path, and got--flake .#runnerinstead of--flake .#matic.The Darwin CI branch already resolved
HOST/DETECTED_HOSTcorrectly, which is why the other two cases in the same spec passed.Change
Both CI branches now resolve
HOSTfirst, thenDETECTED_HOST, and fall back to the existing hardcodedrunnerpath when neither is set. Real CI runs set neither, so therunnerbehavior is unchanged there.Verification
Reproduced the failure and confirmed the fix locally:
CI=true shellspec spec/make_build_host_resolution_spec.shbefore the change: 4 examples, 2 failuresCI=true shellspec: 1635 examples, 0 failuresNot addressed
The
Dockerworkflow failure on main (run 29617921853) was a transientNo space left on devicewhile Nix builtmisefrom source. Five subsequentDockerruns onmainsucceeded, so it is not a persistent breakage and is left alone here.Summary by cubic
Fix CI builds to honor the detected NixOS host so the correct flake target is used. Removes the hardcoded
runnerpath innix-buildandnix-switchCI branches, fixing the failing shellspec cases onmain.nixosConfigurations, resolveHOST, thenDETECTED_HOST; otherwise fall back torunner.nixpkgs#nixos-rebuildwith--flake .#<host>and setHOST/HOSTNAMEaccordingly.Written for commit 1dd9258. Summary will update on new commits.