From 34cefd7dea46e02932c2413ae7068574d0352ce9 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Tue, 9 Apr 2024 08:41:18 +0200 Subject: [PATCH] pkgs/top-level: propagate crossSystem0 via nixpkgsFun This makes combinations work, where pkgsStatic is used on another package set, for example: - Keeps pkgsCross.mingwW64.pkgsStatic.stdenv.hostPlatform.config at "x86_64-w64-mingw32" - Keeps pkgsLLVM.pkgsStatic.stdenv.hostPlatform.useLLVM at "true" Makes pkgsCross.mingwW64.pkgsStatic.stdenv build. Not sure whether it actually builds static executables already, though. Resolves #281596 --- pkgs/test/top-level/default.nix | 2 +- pkgs/top-level/default.nix | 6 +++--- pkgs/top-level/stage.nix | 17 +++++++---------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/pkgs/test/top-level/default.nix b/pkgs/test/top-level/default.nix index fcfb185bbcd6cb..0c75468f70b532 100644 --- a/pkgs/test/top-level/default.nix +++ b/pkgs/test/top-level/default.nix @@ -118,8 +118,8 @@ lib.recurseIntoAttrs { # assert isComposable "pkgsZig"; # TODO: attribute 'abi' missing # assert isComposable "pkgsMusl"; + assert isComposable "pkgsStatic"; # TODO: fails - # assert isComposable "pkgsStatic"; # assert isComposable "pkgsi686Linux"; # Special cases regarding buildPlatform vs hostPlatform diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 526cc5769f0a5b..f535527b2f2e8b 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -44,7 +44,7 @@ let # Rename the function arguments config0 = config; - crossSystem0 = crossSystem; + crossSystem0 = if crossSystem == null then localSystem else crossSystem; in let lib = import ../../lib; @@ -74,7 +74,7 @@ in let # inferred from the system double in `localSystem`. crossSystem = let system = lib.systems.elaborate crossSystem0; in - if crossSystem0 == null || lib.systems.equals system localSystem + if lib.systems.equals system localSystem then localSystem else system; @@ -125,7 +125,7 @@ in let args // lib.optionalAttrs (newArgs ? "localSystem") { localSystem = newArgs.localSystem; } // lib.optionalAttrs (newArgs ? "crossSystem") { - crossSystem = newArgs.crossSystem; + crossSystem = lib.systems.asAttrs crossSystem0 // newArgs.crossSystem; } // lib.optionalAttrs (newArgs ? "overlays") { overlays = overlays ++ newArgs.overlays; }); diff --git a/pkgs/top-level/stage.nix b/pkgs/top-level/stage.nix index 7d0597aed585c9..d4b83d2e472f58 100644 --- a/pkgs/top-level/stage.nix +++ b/pkgs/top-level/stage.nix @@ -219,7 +219,7 @@ let # Bootstrap a cross stdenv using the LLVM toolchain. # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. - crossSystem = stdenv.targetPlatform // { + crossSystem = { useLLVM = true; linker = "lld"; }; @@ -229,7 +229,7 @@ let # Bootstrap a cross stdenv using the Aro C compiler. # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. - crossSystem = stdenv.hostPlatform // { + crossSystem = { useArocc = true; linker = "lld"; }; @@ -239,7 +239,7 @@ let # Bootstrap a cross stdenv using the Zig toolchain. # This is currently not possible when compiling natively, # so we don't need to check hostPlatform != buildPlatform. - crossSystem = stdenv.hostPlatform // { + crossSystem = { useZig = true; linker = "lld"; }; @@ -290,13 +290,10 @@ let pkgsStatic = createPackageSet "pkgsStatic" ({ crossSystem = { isStatic = true; - config = lib.systems.parse.tripleFromSystem ( - if stdenv.hostPlatform.isLinux - then makeMuslParsedPlatform stdenv.hostPlatform.parsed - else stdenv.hostPlatform.parsed - ); - gcc = lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") { abi = "elfv2"; } // - stdenv.hostPlatform.gcc or {}; + } // lib.optionalAttrs stdenv.hostPlatform.isLinux { + config = lib.systems.parse.tripleFromSystem (makeMuslParsedPlatform stdenv.hostPlatform.parsed); + } // lib.optionalAttrs (stdenv.hostPlatform.system == "powerpc64-linux") { + gcc = { abi = "elfv2"; } // stdenv.hostPlatform.gcc or {}; }; });