nixos/nixpkgs: pass original system args instead of elaborated
Passing the elaborated system defeats what pkgs/top-level/default.nix tries to do: Pass only the original args and let defaults be inferred. The underlying problem is that lib.systems.elaborate can not deal with arbitrary overrides, but will often return an inconsistent system description when partially overriding some values. This becomes most prominent if trying to override an already elaborated system.
This commit is contained in:
@@ -844,6 +844,8 @@ let
|
|||||||
|
|
||||||
in warnDeprecation opt //
|
in warnDeprecation opt //
|
||||||
{ value = addErrorContext "while evaluating the option `${showOption loc}':" value;
|
{ value = addErrorContext "while evaluating the option `${showOption loc}':" value;
|
||||||
|
# raw value before "apply" above
|
||||||
|
rawValue = addErrorContext "while evaluating the option `${showOption loc}':" res.mergedValue;
|
||||||
inherit (res.defsFinal') highestPrio;
|
inherit (res.defsFinal') highestPrio;
|
||||||
definitions = map (def: def.value) res.defsFinal;
|
definitions = map (def: def.value) res.defsFinal;
|
||||||
files = map (def: def.file) res.defsFinal;
|
files = map (def: def.file) res.defsFinal;
|
||||||
|
|||||||
@@ -70,19 +70,24 @@ let
|
|||||||
++ lib.optional (opt.localSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.localSystem
|
++ lib.optional (opt.localSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.localSystem
|
||||||
++ lib.optional (opt.crossSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.crossSystem;
|
++ lib.optional (opt.crossSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.crossSystem;
|
||||||
|
|
||||||
|
# pkgs/top-level/default.nix takes great strides to pass the *original* localSystem/crossSystem args
|
||||||
|
# on to nixpkgsFun to create package sets like pkgsStatic, pkgsMusl. This is to be able to infer default
|
||||||
|
# values again. Since cfg.xxxPlatform and cfg.xxxSystem are elaborated via apply, those can't be passed
|
||||||
|
# directly. Instead we use the rawValue before the apply/elaboration step, via opt.xxx.rawValue.
|
||||||
defaultPkgs =
|
defaultPkgs =
|
||||||
if opt.hostPlatform.isDefined then
|
if opt.hostPlatform.isDefined then
|
||||||
let
|
let
|
||||||
|
# This compares elaborated systems on purpose, **not** using rawValue.
|
||||||
isCross = cfg.buildPlatform != cfg.hostPlatform;
|
isCross = cfg.buildPlatform != cfg.hostPlatform;
|
||||||
systemArgs =
|
systemArgs =
|
||||||
if isCross then
|
if isCross then
|
||||||
{
|
{
|
||||||
localSystem = cfg.buildPlatform;
|
localSystem = opt.buildPlatform.rawValue;
|
||||||
crossSystem = cfg.hostPlatform;
|
crossSystem = opt.hostPlatform.rawValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
localSystem = cfg.hostPlatform;
|
localSystem = opt.hostPlatform.rawValue;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
import ../../.. (
|
import ../../.. (
|
||||||
@@ -96,9 +101,9 @@ let
|
|||||||
inherit (cfg)
|
inherit (cfg)
|
||||||
config
|
config
|
||||||
overlays
|
overlays
|
||||||
localSystem
|
|
||||||
crossSystem
|
|
||||||
;
|
;
|
||||||
|
localSystem = opt.localSystem.rawValue;
|
||||||
|
crossSystem = opt.crossSystem.rawValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
|
finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;
|
||||||
|
|||||||
Reference in New Issue
Block a user