Put native system in extra platforms if --system is used

When we use a custom --system arg, we want Nix to also be able to utilize it’s native architecture for builds.

The best use case for this is M1 macOS users who want to prefer x86_64 for compatibility, but sometimes use
aarch64-darwin too. They can now add:

  system = x86_64-darwin

to $HOME/.config/nix/nix.conf without sacrificing ability to build aarch64-darwin.
This commit is contained in:
Matthew Bauer 2021-07-12 16:04:35 -05:00
parent c92fbdb654
commit 85c29bc5a8

View File

@ -136,6 +136,10 @@ StringSet Settings::getDefaultExtraPlatforms()
{ {
StringSet extraPlatforms; StringSet extraPlatforms;
// if custom --system is used, provide native system as extra platform always
if (std::string{SYSTEM} != settings.thisSystem.get())
extraPlatforms.insert(std::string{SYSTEM});
if (std::string{SYSTEM} == "x86_64-linux" && !isWSL1()) if (std::string{SYSTEM} == "x86_64-linux" && !isWSL1())
extraPlatforms.insert("i686-linux"); extraPlatforms.insert("i686-linux");