0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

pkgs/top-level: fix composing "native cross" package sets

When using pkgsCross with a system that ends up the same as the
localSystem, then modifications for package sets like pksgMusl need to
be done for **both** localSystem and crossSystem. Consider the following
on x86_64-linux:

  pkgsCross.gnu64.pkgsMusl

Before this change, this would result in a musl buildPlatform, but a gnu
hostPlatform. This breaks the promise of "stacking" package sets on top
of each other.

After this change, it results in a musl buildPlatform and a musl
hostPlatform. This works better.

One could expect this to result in the same as pkgsCross.musl64, i.e. a
gnu buildPlatform and a musl hostPlatform, however I couldn't get this
to work without increasing memory usage for ci/eval by many, many GB.
This is caused by usage of pkgsi686Linux inside the main package set,
which follows the same hybrid pattern.
This commit is contained in:
Wolfgang Walther 2024-12-21 16:42:40 +01:00
parent 69775e2deb
commit 2acca93bef
No known key found for this signature in database
GPG key ID: B39893FA5F65CAE1
2 changed files with 9 additions and 7 deletions

View file

@ -110,9 +110,8 @@ assert isComposable "pkgsStatic";
assert isComposable "pkgsi686Linux"; assert isComposable "pkgsi686Linux";
# Special cases regarding buildPlatform vs hostPlatform # Special cases regarding buildPlatform vs hostPlatform
# TODO: fails assert discardEvaluationErrors (pkgsCross.gnu64.pkgsMusl.stdenv.hostPlatform.isMusl);
# assert discardEvaluationErrors (pkgsCross.gnu64.pkgsMusl.stdenv.hostPlatform.isMusl); assert discardEvaluationErrors (pkgsCross.gnu64.pkgsi686Linux.stdenv.hostPlatform.isx86_32);
# assert discardEvaluationErrors (pkgsCross.gnu64.pkgsi686Linux.stdenv.hostPlatform.isx86_32);
assert discardEvaluationErrors (pkgsCross.mingwW64.pkgsLinux.stdenv.hostPlatform.isLinux); assert discardEvaluationErrors (pkgsCross.mingwW64.pkgsLinux.stdenv.hostPlatform.isLinux);
assert discardEvaluationErrors ( assert discardEvaluationErrors (
pkgsCross.aarch64-darwin.pkgsx86_64Darwin.stdenv.hostPlatform.isx86_64 pkgsCross.aarch64-darwin.pkgsx86_64Darwin.stdenv.hostPlatform.isx86_64

View file

@ -195,10 +195,13 @@ let
(lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // crossAttrs; (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // crossAttrs;
}); });
# This is only cross when we are already cross, otherwise local. # This is only cross when we are already cross, otherwise local.
mkHybridPkgs = name: hybridAttrs: mkPkgs name (prevArgs: { # For the case of "native cross", i.e. pkgsCross.gnu64 on a x86_64-linux system, we need to adjust **both**
${if stdenv.hostPlatform == stdenv.buildPlatform then "localSystem" else "crossSystem"} = # localSystem **and** crossSystem, otherwise they're out of sync.
(lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // hybridAttrs; mkHybridPkgs = name: hybridAttrs: mkPkgs name (prevArgs: let
}); newSystem = (lib.systems.systemToAttrs (lib.defaultTo prevArgs.localSystem prevArgs.crossSystem or null)) // hybridAttrs;
in { crossSystem = newSystem; }
// lib.optionalAttrs (stdenv.hostPlatform == stdenv.buildPlatform) { localSystem = newSystem; }
);
in self: super: { in self: super: {
# This maps each entry in lib.systems.examples to its own package # This maps each entry in lib.systems.examples to its own package
# set. Each of these will contain all packages cross compiled for # set. Each of these will contain all packages cross compiled for