Inventory/constraints: add id's to inventory constraints to make them more observable
This commit is contained in:
@@ -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 = [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user