lib/modules: Introduce _module.checks.*.check
Previously the .enable option was used to encode the condition as well, which lead to some oddness: - In order to encode an assertion, one had to invert it - To disable a check, one had to mkForce it By introducing a separate .check option this is solved because: - It can be used to encode assertions - Disabling is done separately with .enable option, whose default can be overridden without a mkForce
This commit is contained in:
8
lib/tests/modules/assertions/condition-true.nix
Normal file
8
lib/tests/modules/assertions/condition-true.nix
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
|
||||
_module.checks.test = {
|
||||
check = true;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
_module.checks.test = {
|
||||
enable = false;
|
||||
check = false;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
|
||||
|
||||
@@ -2,20 +2,20 @@
|
||||
|
||||
_module.checks = {
|
||||
test1 = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion 1 failed";
|
||||
};
|
||||
test2 = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion 2 failed";
|
||||
};
|
||||
test3 = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Warning 3 failed";
|
||||
type = "warning";
|
||||
};
|
||||
test4 = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Warning 4 failed";
|
||||
type = "warning";
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
_module.checks.test = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
default = { bar.baz = {}; };
|
||||
type = lib.types.attrsOf (lib.types.attrsOf (lib.types.submodule {
|
||||
_module.checks.test = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
}));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
default = { bar = {}; };
|
||||
type = lib.types.attrsOf (lib.types.submodule {
|
||||
_module.checks.test = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
default = {};
|
||||
type = lib.types.submodule {
|
||||
_module.checks.test = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
|
||||
_module.checks._test = {
|
||||
enable = true;
|
||||
check = false;
|
||||
message = "Assertion failed";
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
|
||||
_module.checks.test = {
|
||||
enable = true;
|
||||
check = false;
|
||||
type = "warning";
|
||||
message = "Warning message";
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user