lib/tests: Add tests for freeform modules
This commit is contained in:
12
lib/tests/modules/define-value-string-properties.nix
Normal file
12
lib/tests/modules/define-value-string-properties.nix
Normal file
@@ -0,0 +1,12 @@
|
||||
{ lib, ... }: {
|
||||
|
||||
imports = [{
|
||||
value = lib.mkDefault "def";
|
||||
}];
|
||||
|
||||
value = lib.mkMerge [
|
||||
(lib.mkIf false "nope")
|
||||
"yes"
|
||||
];
|
||||
|
||||
}
|
||||
3
lib/tests/modules/freeform-attrsOf.nix
Normal file
3
lib/tests/modules/freeform-attrsOf.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{ lib, ... }: {
|
||||
config._module.freeformType = with lib.types; attrsOf (either str (attrsOf str));
|
||||
}
|
||||
3
lib/tests/modules/freeform-lazyAttrsOf.nix
Normal file
3
lib/tests/modules/freeform-lazyAttrsOf.nix
Normal file
@@ -0,0 +1,3 @@
|
||||
{ lib, ... }: {
|
||||
config._module.freeformType = with lib.types; lazyAttrsOf (either str (lazyAttrsOf str));
|
||||
}
|
||||
7
lib/tests/modules/freeform-nested.nix
Normal file
7
lib/tests/modules/freeform-nested.nix
Normal file
@@ -0,0 +1,7 @@
|
||||
{ lib, ... }: {
|
||||
options.nest.foo = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
};
|
||||
config.nest.bar = "bar";
|
||||
}
|
||||
8
lib/tests/modules/freeform-str-dep-unstr.nix
Normal file
8
lib/tests/modules/freeform-str-dep-unstr.nix
Normal 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;
|
||||
}
|
||||
8
lib/tests/modules/freeform-unstr-dep-str.nix
Normal file
8
lib/tests/modules/freeform-unstr-dep-str.nix
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user