diff --git a/pkgs/stdenv/custom/default.nix b/pkgs/stdenv/custom/default.nix index 4c7380118f7d5..7f1fe3e404235 100644 --- a/pkgs/stdenv/custom/default.nix +++ b/pkgs/stdenv/custom/default.nix @@ -2,7 +2,7 @@ , localSystem, crossSystem, config, overlays, crossOverlays ? [] }: -assert crossSystem == localSystem; +assert lib.systems.equals crossSystem localSystem; let bootStages = import ../. { diff --git a/pkgs/stdenv/darwin/default.nix b/pkgs/stdenv/darwin/default.nix index a83f727cfe17c..a51e7622d5357 100644 --- a/pkgs/stdenv/darwin/default.nix +++ b/pkgs/stdenv/darwin/default.nix @@ -36,7 +36,7 @@ } }: -assert crossSystem == localSystem; +assert lib.systems.equals crossSystem localSystem; let inherit (localSystem) system; diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix index 7a2ad665e09d7..bc61a2ab174d9 100644 --- a/pkgs/stdenv/default.nix +++ b/pkgs/stdenv/default.nix @@ -36,7 +36,7 @@ let # Select the appropriate stages for the platform `system'. in - if crossSystem != localSystem || crossOverlays != [] then stagesCross + if !lib.systems.equals crossSystem localSystem || crossOverlays != [] then stagesCross else if config ? replaceStdenv then stagesCustom else if localSystem.isLinux then stagesLinux else if localSystem.isDarwin then stagesDarwin diff --git a/pkgs/stdenv/freebsd/default.nix b/pkgs/stdenv/freebsd/default.nix index de66085876052..c284c9b8948ef 100644 --- a/pkgs/stdenv/freebsd/default.nix +++ b/pkgs/stdenv/freebsd/default.nix @@ -2,7 +2,7 @@ , localSystem, crossSystem, config, overlays, crossOverlays ? [] }: -assert crossSystem == localSystem; +assert lib.systems.equals crossSystem localSystem; let inherit (localSystem) system; fetchURL = import ; trivialBuilder = (import ./trivial-builder.nix); diff --git a/pkgs/stdenv/linux/default.nix b/pkgs/stdenv/linux/default.nix index 9cfe21e3640d4..fb0bc94ad4ca3 100644 --- a/pkgs/stdenv/linux/default.nix +++ b/pkgs/stdenv/linux/default.nix @@ -95,7 +95,7 @@ in files }: -assert crossSystem == localSystem; +assert lib.systems.equals crossSystem localSystem; let inherit (localSystem) system; diff --git a/pkgs/stdenv/native/default.nix b/pkgs/stdenv/native/default.nix index bae4ff2c93b26..38ff1f9c3bcdc 100644 --- a/pkgs/stdenv/native/default.nix +++ b/pkgs/stdenv/native/default.nix @@ -2,7 +2,7 @@ , localSystem, crossSystem, config, overlays, crossOverlays ? [] }: -assert crossSystem == localSystem; +assert lib.systems.equals crossSystem localSystem; let inherit (localSystem) system; diff --git a/pkgs/stdenv/nix/default.nix b/pkgs/stdenv/nix/default.nix index e9e9936ccd801..7089fb8f1bb56 100644 --- a/pkgs/stdenv/nix/default.nix +++ b/pkgs/stdenv/nix/default.nix @@ -4,7 +4,7 @@ , ... }: -assert crossSystem == localSystem; +assert lib.systems.equals crossSystem localSystem; bootStages ++ [ (prevStage: { diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index ba00e78ce2e62..addf7b39a8c95 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -60,11 +60,24 @@ in let localSystem = lib.systems.elaborate args.localSystem; - # Condition preserves sharing which in turn affects equality. + # Condition preserves sharing which in turn improves equality within this Nixpkgs. + # + # Use `lib.systems.equals` to compare systems. crossSystem = - if crossSystem0 == null || crossSystem0 == args.localSystem - then localSystem - else lib.systems.elaborate crossSystem0; + if crossSystem0 == null || lib.systems.equals crossSystem0 args.localSystem + then + # This makes `crossSystem == localSystem` so that comparisons with `==` + # work **in the context of this single Nixpkgs invocation**. + # + # Equality is still broken when comparing between two Nixpkgs instances: + # + # (import {}).stdenv.hostPlatform + # != (import {}).stdenv.hostPlatform + localSystem + else + # It's a truly different system, so no significant equality problems. + # We only have to elaborate it, just like we did for localSystem above. + lib.systems.elaborate crossSystem0; # Allow both: # { /* the config */ } and