lib.systems: expose makeMuslParsedPlatform

Moving this helper from pkgs/stdenv/stage.nix so it can be used
for alternative variations of pkgsMusl and pkgsStatic.
This commit is contained in:
Tobias Mayer
2026-02-14 22:43:12 +01:00
parent f4ec4b2d6b
commit 4cd3967a68
3 changed files with 39 additions and 34 deletions
+35
View File
@@ -974,6 +974,41 @@ rec {
in
"${cpuName}-${vendor.name}-${kernelName kernel}${optExecFormat}${optAbi}";
# 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.
(
x:
lib.trivial.pipe x [
(x: removeAttrs x [ "_type" ])
mkSystem
]
)
(
parsed
// {
abi =
{
gnu = abis.musl;
gnueabi = abis.musleabi;
gnueabihf = abis.musleabihf;
gnuabin32 = abis.muslabin32;
gnuabi64 = abis.muslabi64;
gnuabielfv2 = abis.musl;
gnuabielfv1 = abis.musl;
# The following entries ensure that this function is idempotent.
musleabi = abis.musleabi;
musleabihf = abis.musleabihf;
muslabin32 = abis.muslabin32;
muslabi64 = abis.muslabi64;
}
.${parsed.abi.name} or abis.musl;
}
);
################################################################################
}
+1 -32
View File
@@ -85,36 +85,6 @@ in
}@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: 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;
gnuabielfv2 = lib.systems.parse.abis.musl;
gnuabielfv1 = lib.systems.parse.abis.musl;
# 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
@@ -199,7 +169,6 @@ let
nixpkgsFun
stdenv
overlays
makeMuslParsedPlatform
;
} self super
);
@@ -319,7 +288,7 @@ let
isStatic = true;
config = lib.systems.parse.tripleFromSystem (
if stdenv.hostPlatform.isLinux then
makeMuslParsedPlatform stdenv.hostPlatform.parsed
lib.systems.parse.makeMuslParsedPlatform stdenv.hostPlatform.parsed
else
stdenv.hostPlatform.parsed
);
+3 -2
View File
@@ -10,7 +10,6 @@
stdenv,
nixpkgsFun,
overlays,
makeMuslParsedPlatform,
}:
let
makeLLVMParsedPlatform =
@@ -84,7 +83,9 @@ self: super: {
]
++ overlays;
${if stdenv.hostPlatform == stdenv.buildPlatform then "localSystem" else "crossSystem"} = {
config = lib.systems.parse.tripleFromSystem (makeMuslParsedPlatform stdenv.hostPlatform.parsed);
config = lib.systems.parse.tripleFromSystem (
lib.systems.parse.makeMuslParsedPlatform stdenv.hostPlatform.parsed
);
};
}
else