Inventory/assertions: add seperate assertion layer

This commit is contained in:
Johannes Kirschbauer
2024-11-13 13:52:47 +01:00
parent 22e164b869
commit 3019d7da7e
4 changed files with 30 additions and 1 deletions

View File

@@ -3,7 +3,7 @@
imports = [
./backups.nix
./facts
./inventory/interface.nix
./inventory
./manual.nix
./meta/interface.nix
./metadata.nix

View File

@@ -0,0 +1,6 @@
{
imports = [
./interface.nix
./implementation.nix
];
}

View File

@@ -0,0 +1,6 @@
{ config, ... }:
{
config.assertions = builtins.attrValues (
builtins.mapAttrs (_id: value: value // { inherit _id; }) config.clan.inventory.assertions
);
}

View File

@@ -60,4 +60,21 @@ in
'';
type = lib.types.attrsOf (lib.types.attrsOf instanceOptions);
};
options.clan.inventory.assertions = lib.mkOption {
default = { };
internal = true;
type = lib.types.attrsOf (
# TODO: use NixOS upstream type
lib.types.submodule {
options = {
assertion = lib.mkOption {
type = lib.types.bool;
};
message = lib.mkOption {
type = lib.types.str;
};
};
}
);
};
}