about summary refs log tree commit diff
path: root/nixpkgs/pkgs/top-level/stage.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/top-level/stage.nix')
-rw-r--r--nixpkgs/pkgs/top-level/stage.nix44
1 files changed, 26 insertions, 18 deletions
diff --git a/nixpkgs/pkgs/top-level/stage.nix b/nixpkgs/pkgs/top-level/stage.nix
index 9d34ddb3685f..1945762c50df 100644
--- a/nixpkgs/pkgs/top-level/stage.nix
+++ b/nixpkgs/pkgs/top-level/stage.nix
@@ -64,6 +64,30 @@
 } @args:
 
 let
+  # This is a function from parsed platforms (like
+  # stdenv.hostPlatform.parsed) to parsed platforms.
+  makeMuslParsedPlatform = parsed:
+    # The following line guarantees that the output of this function
+    # is a well-formed platform with no missing fields.  It will be
+    # uncommented in a separate PR, in case it breaks the build.
+    #(x: lib.trivial.pipe x [ (x: builtins.removeAttrs x [ "_type" ]) lib.systems.parse.mkSystem ])
+      (parsed // {
+        abi = {
+          gnu = lib.systems.parse.abis.musl;
+          gnueabi = lib.systems.parse.abis.musleabi;
+          gnueabihf = lib.systems.parse.abis.musleabihf;
+          gnuabin32 = lib.systems.parse.abis.muslabin32;
+          gnuabi64 = lib.systems.parse.abis.muslabi64;
+          # The following two entries ensure that this function is idempotent.
+          musleabi = lib.systems.parse.abis.musleabi;
+          musleabihf = lib.systems.parse.abis.musleabihf;
+          muslabin32 = lib.systems.parse.abis.muslabin32;
+          muslabi64 = lib.systems.parse.abis.muslabi64;
+        }.${parsed.abi.name}
+          or lib.systems.parse.abis.musl;
+      });
+
+
   stdenvAdapters = self: super:
     let
       res = import ../stdenv/adapters.nix {
@@ -188,14 +212,7 @@ let
       })] ++ overlays;
       ${if stdenv.hostPlatform == stdenv.buildPlatform
         then "localSystem" else "crossSystem"} = {
-        parsed = stdenv.hostPlatform.parsed // {
-          abi = {
-            gnu = lib.systems.parse.abis.musl;
-            gnueabi = lib.systems.parse.abis.musleabi;
-            gnueabihf = lib.systems.parse.abis.musleabihf;
-          }.${stdenv.hostPlatform.parsed.abi.name}
-            or lib.systems.parse.abis.musl;
-        };
+        parsed = makeMuslParsedPlatform stdenv.hostPlatform.parsed;
       };
     } else throw "Musl libc only supports Linux systems.";
 
@@ -239,16 +256,7 @@ let
     } // lib.optionalAttrs stdenv.hostPlatform.isLinux {
       crossSystem = {
         isStatic = true;
-        parsed = stdenv.hostPlatform.parsed // {
-          abi = {
-            gnu = lib.systems.parse.abis.musl;
-            gnueabi = lib.systems.parse.abis.musleabi;
-            gnueabihf = lib.systems.parse.abis.musleabihf;
-            musleabi = lib.systems.parse.abis.musleabi;
-            musleabihf = lib.systems.parse.abis.musleabihf;
-          }.${stdenv.hostPlatform.parsed.abi.name}
-            or lib.systems.parse.abis.musl;
-        };
+        parsed = makeMuslParsedPlatform stdenv.hostPlatform.parsed;
       } // lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") {
         gcc.abi = "elfv2";
       };