git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #144094 from hercules-ci/nixos-specialisations-use-extendModules

nixos/specialisation: Rephrase in terms of extendModules, noUserModules

commit8a129f8cf0f30646a699e1eeddaabaec65f2e50f authorRobert Hensing <roberth@users.noreply.github.com> dateWed 1 Dec 2021, 11:03 (5 years ago) parent6752dcdb5681a7
2 files changed+32−21
nixos/lib/eval-config.nix+13−8 nixos/modules/system/activation/top-level.nix+19−13
nixos/lib/eval-config.nix+13−8
@@ -51,23 +51,28 @@ let
5151 };
5252 };
5353
54−in rec {
55−
56− # Merge the option definitions in all modules, forming the full
57− # system configuration.
58− inherit (lib.evalModules {
54+ noUserModules = lib.evalModules {
5955 inherit prefix check;
60− modules = baseModules ++ extraModules ++ [ pkgsModule ] ++ modules;
56+ modules = baseModules ++ extraModules ++ [ pkgsModule ];
6157 args = extraArgs;
6258 specialArgs =
6359 { modulesPath = builtins.toString ../modules; } // specialArgs;
64− }) config options _module type;
60+ };
6561
6662 # These are the extra arguments passed to every module. In
6763 # particular, Nixpkgs is passed through the "pkgs" argument.
6864 extraArgs = extraArgs_ // {
69− inherit baseModules extraModules modules;
65+ inherit noUserModules baseModules extraModules modules;
7066 };
7167
68+in rec {
69+
70+ # Merge the option definitions in all modules, forming the full
71+ # system configuration.
72+ inherit (noUserModules.extendModules { inherit modules; })
73+ config options _module type;
74+
75+ inherit extraArgs;
76+
7277 inherit (_module.args) pkgs;
7378}
nixos/modules/system/activation/top-level.nix+19−13
@@ -1,4 +1,4 @@
1−{ config, lib, pkgs, modules, baseModules, specialArgs, ... }:
1+{ config, lib, pkgs, extendModules, noUserModules, ... }:
22
33with lib;
44
@@ -11,16 +11,10 @@ let
1111 # you can provide an easy way to boot the same configuration
1212 # as you use, but with another kernel
1313 # !!! fix this
14− children = mapAttrs (childName: childConfig:
15− (import ../../../lib/eval-config.nix {
16− inherit lib baseModules specialArgs;
17− system = config.nixpkgs.initialSystem;
18− modules =
19− (optionals childConfig.inheritParentConfig modules)
20− ++ [ ./no-clone.nix ]
21− ++ [ childConfig.configuration ];
22− }).config.system.build.toplevel
23− ) config.specialisation;
14+ children =
15+ mapAttrs
16+ (childName: childConfig: childConfig.configuration.system.build.toplevel)
17+ config.specialisation;
2418
2519 systemBuilder =
2620 let
@@ -169,7 +163,11 @@ in
169163 </screen>
170164 '';
171165 type = types.attrsOf (types.submodule (
172− { ... }: {
166+ local@{ ... }: let
167+ extend = if local.config.inheritParentConfig
168+ then extendModules
169+ else noUserModules.extendModules;
170+ in {
173171 options.inheritParentConfig = mkOption {
174172 type = types.bool;
175173 default = true;
@@ -178,7 +176,15 @@ in
178176
179177 options.configuration = mkOption {
180178 default = {};
181− description = "Arbitrary NixOS configuration options.";
179+ description = ''
180+ Arbitrary NixOS configuration.
181+
182+ Anything you can add to a normal NixOS configuration, you can add
183+ here, including imports and config values, although nested
184+ specialisations will be ignored.
185+ '';
186+ visible = "shallow";
187+ inherit (extend { modules = [ ./no-clone.nix ]; }) type;
182188 };
183189 })
184190 );