0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

Merge pull request #144094 from hercules-ci/nixos-specialisations-use-extendModules

nixos/specialisation: Rephrase in terms of extendModules, noUserModules
This commit is contained in:
Robert Hensing 2021-12-01 11:03:36 +01:00 committed by GitHub
commit 8a129f8cf0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 21 deletions

View file

@ -51,23 +51,28 @@ let
}; };
}; };
in rec { noUserModules = lib.evalModules {
# Merge the option definitions in all modules, forming the full
# system configuration.
inherit (lib.evalModules {
inherit prefix check; inherit prefix check;
modules = baseModules ++ extraModules ++ [ pkgsModule ] ++ modules; modules = baseModules ++ extraModules ++ [ pkgsModule ];
args = extraArgs; args = extraArgs;
specialArgs = specialArgs =
{ modulesPath = builtins.toString ../modules; } // specialArgs; { modulesPath = builtins.toString ../modules; } // specialArgs;
}) config options _module type; };
# These are the extra arguments passed to every module. In # These are the extra arguments passed to every module. In
# particular, Nixpkgs is passed through the "pkgs" argument. # particular, Nixpkgs is passed through the "pkgs" argument.
extraArgs = extraArgs_ // { extraArgs = extraArgs_ // {
inherit baseModules extraModules modules; 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 extraArgs;
inherit (_module.args) pkgs; inherit (_module.args) pkgs;
} }

View file

@ -1,4 +1,4 @@
{ config, lib, pkgs, modules, baseModules, specialArgs, ... }: { config, lib, pkgs, extendModules, noUserModules, ... }:
with lib; with lib;
@ -11,16 +11,10 @@ let
# you can provide an easy way to boot the same configuration # you can provide an easy way to boot the same configuration
# as you use, but with another kernel # as you use, but with another kernel
# !!! fix this # !!! fix this
children = mapAttrs (childName: childConfig: children =
(import ../../../lib/eval-config.nix { mapAttrs
inherit lib baseModules specialArgs; (childName: childConfig: childConfig.configuration.system.build.toplevel)
system = config.nixpkgs.initialSystem; config.specialisation;
modules =
(optionals childConfig.inheritParentConfig modules)
++ [ ./no-clone.nix ]
++ [ childConfig.configuration ];
}).config.system.build.toplevel
) config.specialisation;
systemBuilder = systemBuilder =
let let
@ -169,7 +163,11 @@ in
</screen> </screen>
''; '';
type = types.attrsOf (types.submodule ( type = types.attrsOf (types.submodule (
{ ... }: { local@{ ... }: let
extend = if local.config.inheritParentConfig
then extendModules
else noUserModules.extendModules;
in {
options.inheritParentConfig = mkOption { options.inheritParentConfig = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
@ -178,7 +176,15 @@ in
options.configuration = mkOption { options.configuration = mkOption {
default = {}; default = {};
description = "Arbitrary NixOS configuration options."; 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;
}; };
}) })
); );