[Nix#9605] preferLocalBuild + IFD causes Nix to prefer local builds even when the system doesn't match #86
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
awaiting
author
awaiting
contributors
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
Feature/S3
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lix-project/lix#86
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Upstream-Issue: https://github.com/NixOS/nix/issues/9605
Describe the bug
If you use import-from-derivation (IFD) to build a derivation at evaluation time and the derivation specifies
preferLocalBuild = true;then Nix will prefer to build the derivation on the local system (instead of a remote builder) even if the derivation's system doesn't match the local system. However, if you don't use IFD (i.e. build the derivation by itself in isolation at build time) then Nix respects the derivation's specified system and won't build it locally if the local system doesn't match.The original context for this is that we have a build that used
haskell.lib.packageSourceOverrides(which uses import-from-derivation under the hood viacallCabal2nix) and when we ran the same build for a different system using--systemthen Nix would still try to build the derivation locally despite system mismatch and then the build fails. However, if we disabled local builds (e.g. using--max-jobs 0) then Nix correctly delegates the build to a remote builder.Steps To Reproduce
You can reproduce this by saving the following code to
flake.nix:… then if you
nix buildthat for a system other than the current one (my local system isaarch64-darwin) then it will fail like this:This will fail regardless of whether you have configured a remote builder that supports the desired
system(e.g.x86_64-linuxin the above example) because Nix (incorrectly) prefers to build this derivation locally (and the local system doesn't support the derivation's specified system).However, if you do any of the following then the build will succeed:
preferLocalBuildtofalsethen it will succeed--max-jobs 0to the command (disabling local builds) then it will succeednix-store --realise /nix/store/…-derivation-to-import.drvthen it will succeedThat last bullet point is the primary reason I consider this a bug in Nix and not, say, Nixpkgs, since I'd expect that whether or not a
.drvsuccessfully realizes should be independent of whether it is realized at evaluation time (i.e. import from derivation) or build time.Expected behavior
I expect the original
nix buildcommand to succeed. More generally, I expect any derivation to realize the same regardless of whether it is realized at evaluation time or not.nix-env --versionoutputAdditional context
For reference, the Nix manual has this to say about
preferLocalBuild:… emphasis on "if possible". Nix should only prefer building locally if the local system matches.
Priorities
Add 👍 to issues you find important.