Skip to content

Make platform checks throw BuildError like other failures - #72

Merged
grahamc merged 2 commits into
detsys-mainfrom
gustavderdrache/system-builderror
May 24, 2025
Merged

grahamc merged 2 commits into
detsys-mainfrom
gustavderdrache/system-builderror

Conversation

@gustavderdrache

@gustavderdrache gustavderdrache commented May 23, 2025 •

Copy link
Copy Markdown

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

@github-actions

github-actions Bot commented May 23, 2025 •

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request May 23, 2025 22:13 Inactive
@github-actions
github-actions Bot temporarily deployed to pull request May 23, 2025 23:10 Inactive
@grahamc
grahamc added this pull request to the merge queue May 24, 2025
Merged via the queue into detsys-main with commit 4e08d4a May 24, 2025
@grahamc
grahamc deleted the gustavderdrache/system-builderror branch May 24, 2025 03:14

This branch was previously deployed

1 inactive deployment
pull request — 562ed80b Deployed May 23, 2025 by github-actions[bot]
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.

4 participants