Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "pkgs/top-level: make package sets composable" #376899

Merged
merged 1 commit into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -844,8 +844,6 @@ 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;
Expand Down
15 changes: 5 additions & 10 deletions nixos/modules/misc/nixpkgs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -70,24 +70,19 @@ 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 = opt.buildPlatform.rawValue;
crossSystem = opt.hostPlatform.rawValue;
localSystem = cfg.buildPlatform;
crossSystem = cfg.hostPlatform;
}
else
{
localSystem = opt.hostPlatform.rawValue;
localSystem = cfg.hostPlatform;
};
in
import ../../.. (
Expand All @@ -101,9 +96,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;
Expand Down
128 changes: 0 additions & 128 deletions pkgs/test/top-level/stage.nix

This file was deleted.

18 changes: 11 additions & 7 deletions pkgs/top-level/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -122,18 +122,22 @@ in let
config = lib.showWarnings configEval.config.warnings configEval.config;

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

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