···1+{ lib, pkgs, ... }:
2+let
3+ nixpkgsFun = import ../../top-level;
4+in
5+lib.recurseIntoAttrs {
6+ platformEquality =
7+ let
8+ configsLocal = [
9+ # crossSystem is implicitly set to localSystem.
10+ {
11+ localSystem = { system = "x86_64-linux"; };
12+ }
13+ {
14+ localSystem = { system = "aarch64-linux"; };
15+ crossSystem = null;
16+ }
17+ # Both systems explicitly set to the same string.
18+ {
19+ localSystem = { system = "x86_64-linux"; };
20+ crossSystem = { system = "x86_64-linux"; };
21+ }
22+ # Vendor and ABI inferred from system double.
23+ {
24+ localSystem = { system = "aarch64-linux"; };
25+ crossSystem = { config = "aarch64-unknown-linux-gnu"; };
26+ }
27+ ];
28+ configsCross = [
29+ # GNU is inferred from double, but config explicitly requests musl.
30+ {
31+ localSystem = { system = "aarch64-linux"; };
32+ crossSystem = { config = "aarch64-unknown-linux-musl"; };
33+ }
34+ # Cross-compile from AArch64 to x86-64.
35+ {
36+ localSystem = { system = "aarch64-linux"; };
37+ crossSystem = { system = "x86_64-unknown-linux-gnu"; };
38+ }
39+ ];
40+41+ pkgsLocal = map nixpkgsFun configsLocal;
42+ pkgsCross = map nixpkgsFun configsCross;
43+ in
44+ assert lib.all (p: p.buildPlatform == p.hostPlatform) pkgsLocal;
45+ assert lib.all (p: p.buildPlatform != p.hostPlatform) pkgsCross;
46+ pkgs.emptyFile;
47+}
+14-2
pkgs/top-level/default.nix
···61 localSystem = lib.systems.elaborate args.localSystem;
6263 # Condition preserves sharing which in turn affects equality.
0000000000064 crossSystem =
65- if crossSystem0 == null || crossSystem0 == args.localSystem
066 then localSystem
67- else lib.systems.elaborate crossSystem0;
6869 # Allow both:
70 # { /* the config */ } and
···61 localSystem = lib.systems.elaborate args.localSystem;
6263 # Condition preserves sharing which in turn affects equality.
64+ #
65+ # See `lib.systems.equals` documentation for more details.
66+ #
67+ # Note that it is generally not possible to compare systems as given in
68+ # parameters, e.g. if systems are initialized as
69+ #
70+ # localSystem = { system = "x86_64-linux"; };
71+ # crossSystem = { config = "x86_64-unknown-linux-gnu"; };
72+ #
73+ # Both systems are semantically equivalent as the same vendor and ABI are
74+ # inferred from the system double in `localSystem`.
75 crossSystem =
76+ let system = lib.systems.elaborate crossSystem0; in
77+ if crossSystem0 == null || lib.systems.equals system localSystem
78 then localSystem
79+ else system;
8081 # Allow both:
82 # { /* the config */ } and