From 0b0d2637fca96a4e4d7fac4c40e0773bc218ff53 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Mon, 1 Nov 2021 09:40:27 +0100 Subject: [PATCH] Revert "nixos/specialisation: Rephrase in terms of extendModules, noUserModules" This reverts commit e2bea4427bcf03ae168e45e0bcbd92ac678d91ce. While this commit was probably fine, I want to be conservative with changes right before the release branch-off. So far the extendModules commits have been adding and refactoring expressions that did not affect derivation hashes, whereas this commit changes the module ordering. I will open a separate PR for it. --- nixos/lib/eval-config.nix | 29 +++++++---------- nixos/modules/system/activation/top-level.nix | 32 ++++++++----------- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/nixos/lib/eval-config.nix b/nixos/lib/eval-config.nix index 74b52daa3c8e..69e0a2afdba3 100644 --- a/nixos/lib/eval-config.nix +++ b/nixos/lib/eval-config.nix @@ -51,28 +51,23 @@ let }; }; - noUserModules = lib.evalModules { - inherit prefix check; - modules = baseModules ++ extraModules ++ [ pkgsModule ]; - args = extraArgs; - specialArgs = - { modulesPath = builtins.toString ../modules; } // specialArgs; - }; - - # These are the extra arguments passed to every module. In - # particular, Nixpkgs is passed through the "pkgs" argument. - extraArgs = extraArgs_ // { - inherit noUserModules baseModules extraModules modules; - }; - in rec { # Merge the option definitions in all modules, forming the full # system configuration. - inherit (noUserModules.extendModules { inherit modules; }) - config options _module type; + inherit (lib.evalModules { + inherit prefix check; + modules = baseModules ++ extraModules ++ [ pkgsModule ] ++ modules; + args = extraArgs; + specialArgs = + { modulesPath = builtins.toString ../modules; } // specialArgs; + }) config options _module type; - inherit extraArgs; + # These are the extra arguments passed to every module. In + # particular, Nixpkgs is passed through the "pkgs" argument. + extraArgs = extraArgs_ // { + inherit baseModules extraModules modules; + }; inherit (_module.args) pkgs; } diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix index 8266622e78df..68da910d29cc 100644 --- a/nixos/modules/system/activation/top-level.nix +++ b/nixos/modules/system/activation/top-level.nix @@ -1,4 +1,4 @@ -{ config, lib, pkgs, extendModules, noUserModules, ... }: +{ config, lib, pkgs, modules, baseModules, specialArgs, ... }: with lib; @@ -11,10 +11,16 @@ let # you can provide an easy way to boot the same configuration # as you use, but with another kernel # !!! fix this - children = - mapAttrs - (childName: childConfig: childConfig.configuration.system.build.toplevel) - config.specialisation; + children = mapAttrs (childName: childConfig: + (import ../../../lib/eval-config.nix { + inherit lib baseModules specialArgs; + system = config.nixpkgs.initialSystem; + modules = + (optionals childConfig.inheritParentConfig modules) + ++ [ ./no-clone.nix ] + ++ [ childConfig.configuration ]; + }).config.system.build.toplevel + ) config.specialisation; systemBuilder = let @@ -170,11 +176,7 @@ in ''; type = types.attrsOf (types.submodule ( - local@{ ... }: let - extend = if local.config.inheritParentConfig - then extendModules - else noUserModules.extendModules; - in { + { ... }: { options.inheritParentConfig = mkOption { type = types.bool; default = true; @@ -183,15 +185,7 @@ in options.configuration = mkOption { default = {}; - description = '' - Arbitrary NixOS configuration. - - Anything you can add to a normal NixOS configuration, you can add - here, including imports and config values, although nested - specialisations will be ignored. - ''; - visible = "shallow"; - inherit (extend { modules = [ ./no-clone.nix ]; }) type; + description = "Arbitrary NixOS configuration options."; }; }) );