Compare commits
3 Commits
6a6a371256
...
assertions
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cfe69d7f5 | ||
|
|
1c5257f5fe | ||
|
|
20ad968d04 |
@@ -72,12 +72,19 @@
|
|||||||
clan = {
|
clan = {
|
||||||
meta.name = "clan-core";
|
meta.name = "clan-core";
|
||||||
inventory = {
|
inventory = {
|
||||||
services = { };
|
|
||||||
machines = {
|
machines = {
|
||||||
"test-darwin-machine" = {
|
"test-darwin-machine" = {
|
||||||
machineClass = "darwin";
|
machineClass = "darwin";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
instances = {
|
||||||
|
users = {
|
||||||
|
roles.default.tags."all" = { };
|
||||||
|
roles.default.settings = {
|
||||||
|
user = "root";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
systems = import systems;
|
systems = import systems;
|
||||||
|
|||||||
@@ -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 {
|
options.nixosModule = mkOption {
|
||||||
type = types.deferredModule;
|
type = types.deferredModule;
|
||||||
default = { };
|
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 {
|
options.nixosModule = mkOption {
|
||||||
type = types.deferredModule;
|
type = types.deferredModule;
|
||||||
default = { };
|
default = { };
|
||||||
@@ -877,5 +909,23 @@ in
|
|||||||
}
|
}
|
||||||
) config.result.allMachines;
|
) 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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user