diff --git a/doc/module-system/module-system.chapter.md b/doc/module-system/module-system.chapter.md index 9df7a1672a6..b82a546e4aa 100644 --- a/doc/module-system/module-system.chapter.md +++ b/doc/module-system/module-system.chapter.md @@ -95,3 +95,11 @@ If you do reference multiple `config` (or `options`) from before and after `exte A portion of the configuration tree which is elided from `config`. + +#### `_type` {#module-system-lib-evalModules-return-value-_type} + +A nominal type marker, always `"configuration"`. + +#### `configurationClass` {#module-system-lib-evalModules-return-value-_configurationClass} + +Equal to the [`class` parameter](#module-system-lib-evalModules-param-class). diff --git a/lib/modules.nix b/lib/modules.nix index c6d178e7ff9..5e7f5d7a86d 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -220,16 +220,6 @@ let within a configuration, but can be used in module imports. ''; }; - - _module.class = mkOption { - readOnly = true; - internal = true; - description = lib.mdDoc '' - If the `class` attribute is set and non-`null`, the module system will reject `imports` with a different `class`. - - This option contains the expected `class` attribute of the current module evaluation. - ''; - }; }; config = { @@ -237,7 +227,6 @@ let inherit extendModules; moduleType = type; }; - _module.class = class; _module.specialArgs = specialArgs; }; }; @@ -337,6 +326,7 @@ let config = checked (removeAttrs config [ "_module" ]); _module = checked (config._module); inherit extendModules type; + configurationClass = class; }; in result; diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 8f4553464ad..0aac5b946a3 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -364,6 +364,7 @@ checkConfigOutput '^1$' config.sub.specialisation.value ./extendModules-168767-i # Class checks, evalModules checkConfigOutput '^{ }$' config.ok.config ./class-check.nix +checkConfigOutput '"nixos"' config.ok.configurationClass ./class-check.nix checkConfigError 'The module .*/module-class-is-darwin.nix was imported into nixos instead of darwin.' config.fail.config ./class-check.nix checkConfigError 'The module foo.nix#darwinModules.default was imported into nixos instead of darwin.' config.fail-anon.config ./class-check.nix