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:
Wolfgang Walther
2025-01-25 18:55:03 +01:00
parent b75355ccc3
commit eec21001b0
2 changed files with 12 additions and 5 deletions
+2
View File
@@ -844,6 +844,8 @@ let
in warnDeprecation opt //
{ 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;
definitions = map (def: def.value) res.defsFinal;
files = map (def: def.file) res.defsFinal;
+10 -5
View File
@@ -70,19 +70,24 @@ let
++ lib.optional (opt.localSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.localSystem
++ 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 =
if opt.hostPlatform.isDefined then
let
# This compares elaborated systems on purpose, **not** using rawValue.
isCross = cfg.buildPlatform != cfg.hostPlatform;
systemArgs =
if isCross then
{
localSystem = cfg.buildPlatform;
crossSystem = cfg.hostPlatform;
localSystem = opt.buildPlatform.rawValue;
crossSystem = opt.hostPlatform.rawValue;
}
else
{
localSystem = cfg.hostPlatform;
localSystem = opt.hostPlatform.rawValue;
};
in
import ../../.. (
@@ -96,9 +101,9 @@ let
inherit (cfg)
config
overlays
localSystem
crossSystem
;
localSystem = opt.localSystem.rawValue;
crossSystem = opt.crossSystem.rawValue;
};
finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;