Skip to content

Commit 42143ec

Browse files
authored
Revert "pkgs/top-level: make package sets composable" (#376899)
2 parents 0b6fad0 + 7c251e2 commit 42143ec

File tree

5 files changed

+139
-230
lines changed

5 files changed

+139
-230
lines changed

lib/modules.nix

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -844,8 +844,6 @@ let
844844

845845
in warnDeprecation opt //
846846
{ value = addErrorContext "while evaluating the option `${showOption loc}':" value;
847-
# raw value before "apply" above
848-
rawValue = addErrorContext "while evaluating the option `${showOption loc}':" res.mergedValue;
849847
inherit (res.defsFinal') highestPrio;
850848
definitions = map (def: def.value) res.defsFinal;
851849
files = map (def: def.file) res.defsFinal;

nixos/modules/misc/nixpkgs.nix

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,19 @@ let
7070
++ lib.optional (opt.localSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.localSystem
7171
++ lib.optional (opt.crossSystem.highestPrio < (lib.mkOptionDefault { }).priority) opt.crossSystem;
7272

73-
# pkgs/top-level/default.nix takes great strides to pass the *original* localSystem/crossSystem args
74-
# on to nixpkgsFun to create package sets like pkgsStatic, pkgsMusl. This is to be able to infer default
75-
# values again. Since cfg.xxxPlatform and cfg.xxxSystem are elaborated via apply, those can't be passed
76-
# directly. Instead we use the rawValue before the apply/elaboration step, via opt.xxx.rawValue.
7773
defaultPkgs =
7874
if opt.hostPlatform.isDefined then
7975
let
80-
# This compares elaborated systems on purpose, **not** using rawValue.
8176
isCross = cfg.buildPlatform != cfg.hostPlatform;
8277
systemArgs =
8378
if isCross then
8479
{
85-
localSystem = opt.buildPlatform.rawValue;
86-
crossSystem = opt.hostPlatform.rawValue;
80+
localSystem = cfg.buildPlatform;
81+
crossSystem = cfg.hostPlatform;
8782
}
8883
else
8984
{
90-
localSystem = opt.hostPlatform.rawValue;
85+
localSystem = cfg.hostPlatform;
9186
};
9287
in
9388
import ../../.. (
@@ -101,9 +96,9 @@ let
10196
inherit (cfg)
10297
config
10398
overlays
99+
localSystem
100+
crossSystem
104101
;
105-
localSystem = opt.localSystem.rawValue;
106-
crossSystem = opt.crossSystem.rawValue;
107102
};
108103

109104
finalPkgs = if opt.pkgs.isDefined then cfg.pkgs.appendOverlays cfg.overlays else defaultPkgs;

pkgs/test/top-level/stage.nix

Lines changed: 0 additions & 128 deletions
This file was deleted.

pkgs/top-level/default.nix

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,18 +122,22 @@ in let
122122
config = lib.showWarnings configEval.config.warnings configEval.config;
123123

124124
# A few packages make a new package set to draw their dependencies from.
125-
# Rather than give `all-packages.nix` all the arguments to this function,
126-
# even ones that don't concern it, we give it this function to "re-call"
127-
# nixpkgs, inheriting whatever arguments it doesn't explicitly provide. This
128-
# way, `all-packages.nix` doesn't know more than it needs to.
125+
# (Currently to get a cross tool chain, or forced-i686 package.) Rather than
126+
# give `all-packages.nix` all the arguments to this function, even ones that
127+
# don't concern it, we give it this function to "re-call" nixpkgs, inheriting
128+
# whatever arguments it doesn't explicitly provide. This way,
129+
# `all-packages.nix` doesn't know more than it needs too.
129130
#
130131
# It's OK that `args` doesn't include default arguments from this file:
131132
# they'll be deterministically inferred. In fact we must *not* include them,
132133
# because it's important that if some parameter which affects the default is
133134
# substituted with a different argument, the default is re-inferred.
134135
#
135-
# To put this in concrete terms, we want the provided non-native `localSystem`
136-
# and `crossSystem` arguments to affect the stdenv chosen.
136+
# To put this in concrete terms, this function is basically just used today to
137+
# use package for a different platform for the current platform (namely cross
138+
# compiling toolchains and 32-bit packages on x86_64). In both those cases we
139+
# want the provided non-native `localSystem` argument to affect the stdenv
140+
# chosen.
137141
#
138142
# NB!!! This thing gets its `config` argument from `args`, i.e. it's actually
139143
# `config0`. It is important to keep it to `config0` format (as opposed to the
@@ -142,7 +146,7 @@ in let
142146
# via `evalModules` is not idempotent. In other words, if you add `config` to
143147
# `newArgs`, expect strange very hard to debug errors! (Yes, I'm speaking from
144148
# experience here.)
145-
nixpkgsFun = f0: import ./. (args // f0 args);
149+
nixpkgsFun = newArgs: import ./. (args // newArgs);
146150

147151
# Partially apply some arguments for building bootstraping stage pkgs
148152
# sets. Only apply arguments which no stdenv would want to override.

0 commit comments

Comments
 (0)