This commit is contained in:
Johannes Kirschbauer
2025-07-12 13:47:30 +02:00
committed by Jörg Thalheim
parent 1c5257f5fe
commit 4cfe69d7f5
2 changed files with 58 additions and 1 deletions

View File

@@ -418,6 +418,29 @@ in
```
'';
};
options.assertions = mkOption {
default = { };
description = ''
Assertions for the instance.
This is a set of assertions that should be checked during the evaluation of the instance.
If any assertion fails, an error is thrown.
Example:
```nix
{
assertions = {
timeout = {
assertion = "settings.timeout > 0";
message = "Timeout must be greater than 0";
};
};
}
```
'';
type = types.attrsOf types.raw;
};
options.nixosModule = mkOption {
type = types.deferredModule;
default = { };
@@ -553,6 +576,15 @@ in
```
'';
};
options.assertions = mkOption {
default = { };
description = ''
Assertions for the machine.
See instance assertions for more information.
'';
type = types.attrsOf types.raw;
};
options.nixosModule = mkOption {
type = types.deferredModule;
default = { };
@@ -877,5 +909,23 @@ in
}
) config.result.allMachines;
};
debug = mkOption {
default = { };
# result.allRoles.default.allInstances.users.allMachines.flash-installer
};
};
config.result.assertions = lib.concatMapAttrs (
roleName: role:
lib.concatMapAttrs (
instanceName: instance:
lib.concatMapAttrs (
machineName: machine:
lib.mapAttrs' (assertion_id: value: {
name = "${assertion_id} (instance=${instanceName}; role=${roleName}; machine=${machineName};)";
inherit value;
}) machine.assertions
) instance.allMachines
) role.allInstances
) config.result.allRoles;
}