Inventory: init inventory.tags for globally defined static and dynamic tags
This commit is contained in:
33
lib/build-clan/computed-tags.nix
Normal file
33
lib/build-clan/computed-tags.nix
Normal 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
|
||||
);
|
||||
}
|
||||
)
|
||||
);
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -162,6 +162,8 @@ in
|
||||
#
|
||||
# config.inventory.meta <- config.meta
|
||||
{ inventory.meta = config.meta; }
|
||||
# Set default for computed tags
|
||||
./computed-tags.nix
|
||||
];
|
||||
|
||||
inherit nixosConfigurations;
|
||||
|
||||
Reference in New Issue
Block a user