···11+{ lib, pkgs, ... }:
22+let
33+ nixpkgsFun = import ../../top-level;
44+in
55+lib.recurseIntoAttrs {
66+ platformEquality =
77+ let
88+ configsLocal = [
99+ # crossSystem is implicitly set to localSystem.
1010+ {
1111+ localSystem = { system = "x86_64-linux"; };
1212+ }
1313+ {
1414+ localSystem = { system = "aarch64-linux"; };
1515+ crossSystem = null;
1616+ }
1717+ # Both systems explicitly set to the same string.
1818+ {
1919+ localSystem = { system = "x86_64-linux"; };
2020+ crossSystem = { system = "x86_64-linux"; };
2121+ }
2222+ # Vendor and ABI inferred from system double.
2323+ {
2424+ localSystem = { system = "aarch64-linux"; };
2525+ crossSystem = { config = "aarch64-unknown-linux-gnu"; };
2626+ }
2727+ ];
2828+ configsCross = [
2929+ # GNU is inferred from double, but config explicitly requests musl.
3030+ {
3131+ localSystem = { system = "aarch64-linux"; };
3232+ crossSystem = { config = "aarch64-unknown-linux-musl"; };
3333+ }
3434+ # Cross-compile from AArch64 to x86-64.
3535+ {
3636+ localSystem = { system = "aarch64-linux"; };
3737+ crossSystem = { system = "x86_64-unknown-linux-gnu"; };
3838+ }
3939+ ];
4040+4141+ pkgsLocal = map nixpkgsFun configsLocal;
4242+ pkgsCross = map nixpkgsFun configsCross;
4343+ in
4444+ assert lib.all (p: p.buildPlatform == p.hostPlatform) pkgsLocal;
4545+ assert lib.all (p: p.buildPlatform != p.hostPlatform) pkgsCross;
4646+ pkgs.emptyFile;
4747+}
+14-2
pkgs/top-level/default.nix
···6161 localSystem = lib.systems.elaborate args.localSystem;
62626363 # Condition preserves sharing which in turn affects equality.
6464+ #
6565+ # See `lib.systems.equals` documentation for more details.
6666+ #
6767+ # Note that it is generally not possible to compare systems as given in
6868+ # parameters, e.g. if systems are initialized as
6969+ #
7070+ # localSystem = { system = "x86_64-linux"; };
7171+ # crossSystem = { config = "x86_64-unknown-linux-gnu"; };
7272+ #
7373+ # Both systems are semantically equivalent as the same vendor and ABI are
7474+ # inferred from the system double in `localSystem`.
6475 crossSystem =
6565- if crossSystem0 == null || crossSystem0 == args.localSystem
7676+ let system = lib.systems.elaborate crossSystem0; in
7777+ if crossSystem0 == null || lib.systems.equals system localSystem
6678 then localSystem
6767- else lib.systems.elaborate crossSystem0;
7979+ else system;
68806981 # Allow both:
7082 # { /* the config */ } and