Skip to content

Make platform checks throw BuildError like other failures (backport #13278) #13603

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 2.28-maintenance
Choose a base branch
from

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Jul 30, 2025

Motivation

Some complex derivations can depend on multiple systems. In cases where these aren't already cached (or locally buildable), Nix throws an error indicating that a derivation cannot be built. However, this does not behave the same with respect to other build errors. This PR changes the error to throw BuildError, allowing Nix to report the dependency tree that led to the build error, if any.

In the examples below, needs-* depends on a derivation that fails for the various scenarios I've tested locally.

Mismatched system

Before:

$ nix build .#needs-system
error: a 'bogus' with features {} is required to build '/nix/store/1aj7zljmh3zwff9z0pcan940kghql87c-bad-system.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}

After:

$ nix build .#needs-system
error: Cannot build '/nix/store/1aj7zljmh3zwff9z0pcan940kghql87c-bad-system.drv'.
       Reason: required system or feature not available
       Required system: 'bogus' with features {}
       Current system: 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}
error: Cannot build '/nix/store/xw31yf7yldxk163858vb8n51j9zbwnz7-needs-system.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/9qralxw4zvb5s9cii2lv04l66nygr95r-needs-system

Missing required feature

Before:

$ nix build .#needs-feature
error: a 'x86_64-linux' with features {bogus} is required to build '/nix/store/cny1i79kcnj8cbzm17bzmnn6f74jl0rr-bad-feature.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}

After:

$ nix build .#needs-feature
error: Cannot build '/nix/store/cny1i79kcnj8cbzm17bzmnn6f74jl0rr-bad-feature.drv'.
       Reason: required system or feature not available
       Required system: 'x86_64-linux' with features {bogus}
       Current system: 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}
error: Cannot build '/nix/store/ki2sn6hb4mkv0sg6c676lllmzs2alzxd-needs-feature.drv'.
       Reason: 1 dependency failed.
       Output paths:
         /nix/store/q8mp4h0s6g0qq6z72kwidlp5a7m7a9qx-needs-feature

Rosetta not installed

(Note that I don't have a Mac to test on, but I've used --system passed to sudo nix build to generate this error.)

Before:

$ nix build .#mac-system
error: run `/usr/sbin/softwareupdate --install-rosetta` to enable your aarch64-darwin to run programs for x86_64-darwin

After:

$ nix build .#mac-system
error: Cannot build '/nix/store/2iq7bj3zgsggbn1q6vdn79fk1wiksldy-mac-system.drv'.
       Reason: required system or feature not available
       Required system: 'x86_64-darwin' with features {}
       Current system: 'aarch64-darwin' with features {benchmark, big-parallel, kvm, nixos-test, uid-range}
       Note: run `/usr/sbin/softwareupdate --install-rosetta` to run programs for x86_64-darwin

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.


This is an automatic backport of pull request #13278 done by [Mergify](https://mergify.com).

Co-authored-by: Cole Helbling <cole.e.helbling@outlook.com>
(cherry picked from commit b04962b)

# Conflicts:
#	src/libstore/unix/build/local-derivation-goal.cc
@mergify mergify bot requested a review from Ericson2314 as a code owner July 30, 2025 12:25
@mergify mergify bot added automatic backport This PR is a backport produced by automation (does not trigger backporting) conflicts merge-queue labels Jul 30, 2025
Copy link
Contributor Author

mergify bot commented Jul 30, 2025

Cherry-pick of b04962b has failed:

On branch mergify/bp/2.28-maintenance/pr-13278
Your branch is up to date with 'origin/2.28-maintenance'.

You are currently cherry-picking commit b04962b33.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   src/libstore/unix/build/local-derivation-goal.cc

no changes added to commit (use "git add" and/or "git commit -a")

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@mergify mergify bot added the automatic backport This PR is a backport produced by automation (does not trigger backporting) label Jul 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automatic backport This PR is a backport produced by automation (does not trigger backporting) conflicts merge-queue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant