diff options
author | Ivan Trubach <mr.trubach@icloud.com> | 2023-09-12 16:55:32 +0300 |
---|---|---|
committer | Ivan Trubach <mr.trubach@icloud.com> | 2023-09-13 07:22:52 +0300 |
commit | d4063e0330ec9f68037d4dbdd12aec3376e679ba (patch) | |
tree | 61a70c87a586a1ae04e93e2edd50db7f23f4615b /pkgs/test/top-level | |
parent | 240cbdc845436995fa10fdc781c58a069f326d8f (diff) |
pkgs/top-level: use lib.systems.equals for crossSystem
Fixes otherwise equivalent systems being treated as different by packages that compare `stdenv.*Platform`s using `==` operator.
Diffstat (limited to 'pkgs/test/top-level')
-rw-r--r-- | pkgs/test/top-level/default.nix | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/pkgs/test/top-level/default.nix b/pkgs/test/top-level/default.nix new file mode 100644 index 0000000000000..fdb9fe09a88b8 --- /dev/null +++ b/pkgs/test/top-level/default.nix @@ -0,0 +1,47 @@ +{ lib, pkgs, ... }: +let + nixpkgsFun = import ../../top-level; +in +lib.recurseIntoAttrs { + platformEquality = + let + configsLocal = [ + # crossSystem is implicitly set to localSystem. + { + localSystem = { system = "x86_64-linux"; }; + } + { + localSystem = { system = "aarch64-linux"; }; + crossSystem = null; + } + # Both systems explicitly set to the same string. + { + localSystem = { system = "x86_64-linux"; }; + crossSystem = { system = "x86_64-linux"; }; + } + # Vendor and ABI inferred from system double. + { + localSystem = { system = "aarch64-linux"; }; + crossSystem = { config = "aarch64-unknown-linux-gnu"; }; + } + ]; + configsCross = [ + # GNU is inferred from double, but config explicitly requests musl. + { + localSystem = { system = "aarch64-linux"; }; + crossSystem = { config = "aarch64-unknown-linux-musl"; }; + } + # Cross-compile from AArch64 to x86-64. + { + localSystem = { system = "aarch64-linux"; }; + crossSystem = { system = "x86_64-unknown-linux-gnu"; }; + } + ]; + + pkgsLocal = map nixpkgsFun configsLocal; + pkgsCross = map nixpkgsFun configsCross; + in + assert lib.all (p: p.buildPlatform == p.hostPlatform) pkgsLocal; + assert lib.all (p: p.buildPlatform != p.hostPlatform) pkgsCross; + pkgs.emptyFile; +} |