From 8a5d99f6d2551f33086583644ce7ef6d36d78cac Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Wed, 13 Nov 2024 13:52:47 +0100 Subject: [PATCH] Inventory/assertions: add seperate assertion layer --- nixosModules/clanCore/default.nix | 2 +- nixosModules/clanCore/inventory/default.nix | 6 ++++++ .../clanCore/inventory/implementation.nix | 6 ++++++ nixosModules/clanCore/inventory/interface.nix | 17 +++++++++++++++++ 4 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 nixosModules/clanCore/inventory/default.nix create mode 100644 nixosModules/clanCore/inventory/implementation.nix diff --git a/nixosModules/clanCore/default.nix b/nixosModules/clanCore/default.nix index 020179a27..e48a50d4b 100644 --- a/nixosModules/clanCore/default.nix +++ b/nixosModules/clanCore/default.nix @@ -3,7 +3,7 @@ imports = [ ./backups.nix ./facts - ./inventory/interface.nix + ./inventory ./manual.nix ./meta/interface.nix ./metadata.nix diff --git a/nixosModules/clanCore/inventory/default.nix b/nixosModules/clanCore/inventory/default.nix new file mode 100644 index 000000000..274989a40 --- /dev/null +++ b/nixosModules/clanCore/inventory/default.nix @@ -0,0 +1,6 @@ +{ + imports = [ + ./interface.nix + ./implementation.nix + ]; +} diff --git a/nixosModules/clanCore/inventory/implementation.nix b/nixosModules/clanCore/inventory/implementation.nix new file mode 100644 index 000000000..f8ae3e37e --- /dev/null +++ b/nixosModules/clanCore/inventory/implementation.nix @@ -0,0 +1,6 @@ +{ config, ... }: +{ + config.assertions = builtins.attrValues ( + builtins.mapAttrs (_id: value: value // { inherit _id; }) config.clan.inventory.assertions + ); +} diff --git a/nixosModules/clanCore/inventory/interface.nix b/nixosModules/clanCore/inventory/interface.nix index c625af548..e739f6087 100644 --- a/nixosModules/clanCore/inventory/interface.nix +++ b/nixosModules/clanCore/inventory/interface.nix @@ -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; + }; + }; + } + ); + }; }