lib/tests: Add tests for freeform modules

This commit is contained in:
Silvan Mosberger
2020-03-22 20:55:54 +01:00
parent 2d45a62899
commit 446d80d28d
7 changed files with 62 additions and 0 deletions

View File

@@ -0,0 +1,12 @@
{ lib, ... }: {
imports = [{
value = lib.mkDefault "def";
}];
value = lib.mkMerge [
(lib.mkIf false "nope")
"yes"
];
}

View File

@@ -0,0 +1,3 @@
{ lib, ... }: {
config._module.freeformType = with lib.types; attrsOf (either str (attrsOf str));
}

View File

@@ -0,0 +1,3 @@
{ lib, ... }: {
config._module.freeformType = with lib.types; lazyAttrsOf (either str (lazyAttrsOf str));
}

View File

@@ -0,0 +1,7 @@
{ lib, ... }: {
options.nest.foo = lib.mkOption {
type = lib.types.bool;
default = false;
};
config.nest.bar = "bar";
}

View File

@@ -0,0 +1,8 @@
{ lib, config, ... }: {
options.foo = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
config.foo = lib.mkIf (config ? value) config.value;
}

View File

@@ -0,0 +1,8 @@
{ lib, config, ... }: {
options.value = lib.mkOption {
type = lib.types.nullOr lib.types.str;
default = null;
};
config.foo = lib.mkIf (config.value != null) config.value;
}