about summary refs log tree commit diff
path: root/pkgs/test
diff options
context:
space:
mode:
authorRobert Hensing <roberth@users.noreply.github.com>2023-09-13 12:04:45 +0200
committerGitHub <noreply@github.com>2023-09-13 12:04:45 +0200
commit04311ac3fa351a2e80a778b77b6ddbe82c698ce6 (patch)
tree111662d0f529632e90365a474eb6c25871c30cdb /pkgs/test
parentdc8866c22f79deb2848b9d48b25530f2b9757c92 (diff)
parentd4063e0330ec9f68037d4dbdd12aec3376e679ba (diff)
downloadnixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.tar
nixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.tar.gz
nixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.tar.bz2
nixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.tar.lz
nixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.tar.xz
nixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.tar.zst
nixlib-04311ac3fa351a2e80a778b77b6ddbe82c698ce6.zip
Merge pull request #254763 from tie/nixpkgs-systems-equals
pkgs/top-level: use lib.systems.equals for crossSystem
Diffstat (limited to 'pkgs/test')
-rw-r--r--pkgs/test/default.nix2
-rw-r--r--pkgs/test/top-level/default.nix47
2 files changed, 49 insertions, 0 deletions
diff --git a/pkgs/test/default.nix b/pkgs/test/default.nix
index b914ec26ae00..05d8ee61e9a5 100644
--- a/pkgs/test/default.nix
+++ b/pkgs/test/default.nix
@@ -94,6 +94,8 @@ with pkgs;
 
   config = callPackage ./config.nix { };
 
+  top-level = callPackage ./top-level { };
+
   haskell = callPackage ./haskell { };
 
   hooks = callPackage ./hooks { };
diff --git a/pkgs/test/top-level/default.nix b/pkgs/test/top-level/default.nix
new file mode 100644
index 000000000000..fdb9fe09a88b
--- /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;
+}