Skip to content

Commit

Permalink
pkgs/top-level: propagate crossSystem0 via nixpkgsFun
Browse files Browse the repository at this point in the history
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 NixOS#281596
  • Loading branch information
wolfgangwalther committed Sep 25, 2024
1 parent e0fcfab commit 34cefd7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion pkgs/test/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions pkgs/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
});
Expand Down
17 changes: 7 additions & 10 deletions pkgs/top-level/stage.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
};
Expand All @@ -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";
};
Expand All @@ -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";
};
Expand Down Expand Up @@ -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 {};
};
});

Expand Down

0 comments on commit 34cefd7

Please sign in to comment.