Inventory/constraints: add id's to inventory constraints to make them more observable

This commit is contained in:
Johannes Kirschbauer
2024-11-13 13:58:43 +01:00
parent 527769e060
commit 280878e30a
6 changed files with 255 additions and 229 deletions

View File

@@ -1,9 +1,19 @@
{ lib, allRoles, ... }:
{
lib,
allRoles,
moduleName,
...
}:
let
inherit (lib) mkOption types;
rolesAttrs = builtins.groupBy lib.id allRoles;
in
{
options.serviceName = mkOption {
type = types.str;
default = moduleName;
readOnly = true;
};
options.roles = lib.mapAttrs (
_name: _:
mkOption {
@@ -20,10 +30,6 @@ in
type = types.int;
default = 0;
};
eq = mkOption {
type = types.nullOr types.int;
default = null;
};
};
}
];
@@ -31,10 +37,26 @@ in
}
) rolesAttrs;
options.instances = mkOption {
default = { };
type = types.submoduleWith {
modules = [
{
options = {
max = mkOption {
type = types.nullOr types.int;
default = null;
};
};
}
];
};
};
# The resulting assertions
options.assertions = mkOption {
default = [ ];
type = types.listOf (
default = { };
type = types.attrsOf (
types.submoduleWith {
modules = [
{