lib.modules: Add _prefix module argument

This commit is contained in:
Robert Hensing
2025-04-15 12:42:47 +02:00
parent 7de47524a7
commit 4752577dd6
3 changed files with 21 additions and 0 deletions
+1
View File
@@ -258,6 +258,7 @@ let
specialArgs
;
_class = class;
_prefix = prefix;
}
// specialArgs
);
+3
View File
@@ -352,6 +352,9 @@ checkConfigOutput '^"submodule"$' options.submodule.type.description ./declare-s
## Paths should be allowed as values and work as expected
checkConfigOutput '^true$' config.submodule.enable ./declare-submoduleWith-path.nix
## _prefix module argument is available at import time and contains the prefix
checkConfigOutput '^true$' config.foo.ok ./prefix-module-argument.nix
## deferredModule
# default module is merged into nodes.foo
checkConfigOutput '"beta"' config.nodes.foo.settingsDict.c ./deferred-module.nix
@@ -0,0 +1,17 @@
{ lib, ... }:
{
options.foo = lib.mkOption {
type = lib.types.submodule { };
default = { };
};
config = {
foo =
{ _prefix, ... }:
assert _prefix == [ "foo" ];
{
options.ok = lib.mkOption { };
config.ok = true;
};
};
}