about summary refs log tree commit diff
path: root/pkgs/top-level/impure.nix
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2018-06-24 23:15:09 -0400
committerMatthew Bauer <mjbauer95@gmail.com>2018-06-25 17:13:02 -0400
commit31eac6fd0088710c193efebb632f1c97ef3045a6 (patch)
tree337cb0a047bab6d89bc1d69ad307871da08245da /pkgs/top-level/impure.nix
parent5000cc555eb35292e3819f73ee497957d1311ab0 (diff)
impure.nix: fix handling of localSystem
If we passed a localSystem in, we don’t want the current system to
override it. Now we check for localSystem first to avoid getting
"mixed" localSystem values from commands like this:

  nix-build --arg localSystem '{config="x86_64-unknown-linux-musl";}' -A hello

Which would eventually evaluate localSystem to this:

{
  config = "x86_64-unknown-linux-musl";
  system = "x86_64-darwin";
}

& Nix would not be able to run it correctly.

Fixes #41599

/cc @Ericson2314
Diffstat (limited to 'pkgs/top-level/impure.nix')
-rw-r--r--pkgs/top-level/impure.nix3
1 files changed, 2 insertions, 1 deletions
diff --git a/pkgs/top-level/impure.nix b/pkgs/top-level/impure.nix
index df462665dd160..dafa351c4e418 100644
--- a/pkgs/top-level/impure.nix
+++ b/pkgs/top-level/impure.nix
@@ -83,5 +83,6 @@ import ./. (builtins.removeAttrs args [ "system" "platform" ] // {
   inherit config overlays crossSystem;
   # Fallback: Assume we are building packages on the current (build, in GNU
   # Autotools parlance) system.
-  localSystem = { system = builtins.currentSystem; } // localSystem;
+  localSystem = (if args ? localSystem then {}
+                 else { system = builtins.currentSystem; }) // localSystem;
 })