From 4cd3967a684091febad25c9fc56d2cb29997fce6 Mon Sep 17 00:00:00 2001 From: Tobias Mayer Date: Sat, 14 Feb 2026 22:43:12 +0100 Subject: [PATCH] lib.systems: expose makeMuslParsedPlatform Moving this helper from pkgs/stdenv/stage.nix so it can be used for alternative variations of pkgsMusl and pkgsStatic. --- lib/systems/parse.nix | 35 +++++++++++++++++++++++++++++++++++ pkgs/top-level/stage.nix | 33 +-------------------------------- pkgs/top-level/variants.nix | 5 +++-- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/lib/systems/parse.nix b/lib/systems/parse.nix index 86f8c169d901..0fa734207f33 100644 --- a/lib/systems/parse.nix +++ b/lib/systems/parse.nix @@ -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; + } + ); + ################################################################################ } diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 34edecf6d968..1576ff3dc89d 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -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 ); diff --git a/pkgs/top-level/variants.nix b/pkgs/top-level/variants.nix index e3a12fcadcf5..f908ca89402b 100644 --- a/pkgs/top-level/variants.nix +++ b/pkgs/top-level/variants.nix @@ -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