Inventory: init inventory.tags for globally defined static and dynamic tags

This commit is contained in:
Johannes Kirschbauer
2024-11-08 12:48:03 +01:00
parent 34873828ed
commit 4994b5acb5
6 changed files with 395 additions and 222 deletions

View File

@@ -0,0 +1,33 @@
{
config,
lib,
...
}:
{
config.inventory = {
tags = (
{ machines, ... }:
{
# Only compute the default value
# The option MUST be defined in ./build-inventory/interface.nix
all = lib.mkDefault (builtins.attrNames machines);
}
);
};
# Add the computed tags to machine tags for displaying them
options.inventory = {
machines = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule (
# 'name' is the machines attribute-name
{ name, ... }:
{
tags = builtins.attrNames (
lib.filterAttrs (_t: tagMemers: builtins.elem name tagMemers) config.inventory.tags
);
}
)
);
};
};
}

View File

@@ -162,6 +162,8 @@ in
#
# config.inventory.meta <- config.meta
{ inventory.meta = config.meta; }
# Set default for computed tags
./computed-tags.nix
];
inherit nixosConfigurations;