inventory: don't check if tag is used in inventory

this doesn't work with flake-parts
This commit is contained in:
Jörg Thalheim
2024-07-15 17:29:24 +02:00
committed by Johannes Kirschbauer
parent 7d028790d9
commit cc5c027d92

View File

@@ -1,16 +1,16 @@
{ config, lib, ... }: { config, lib, ... }:
let let
t = lib.types; types = lib.types;
metaOptions = { metaOptions = {
name = lib.mkOption { type = t.str; }; name = lib.mkOption { type = types.str; };
description = lib.mkOption { description = lib.mkOption {
default = null; default = null;
type = t.nullOr t.str; type = types.nullOr types.str;
}; };
icon = lib.mkOption { icon = lib.mkOption {
default = null; default = null;
type = t.nullOr t.str; type = types.nullOr types.str;
}; };
}; };
@@ -21,34 +21,20 @@ let
merge = lib.mergeEqualOption; merge = lib.mergeEqualOption;
}; };
allTags = lib.unique (
lib.foldlAttrs (
tags: _: m:
tags ++ m.tags or [ ]
) [ ] config.machines
);
tagRef = lib.mkOptionType {
name = "str";
description = "Tags :: [${builtins.concatStringsSep " | " allTags}]";
check = v: lib.isString v && builtins.elem v allTags;
merge = lib.mergeEqualOption;
};
moduleConfig = lib.mkOption { moduleConfig = lib.mkOption {
default = { }; default = { };
type = t.attrsOf t.anything; type = types.attrsOf types.anything;
}; };
importsOption = lib.mkOption { importsOption = lib.mkOption {
default = [ ]; default = [ ];
type = t.listOf t.str; type = types.listOf types.str;
}; };
in in
{ {
options = { options = {
assertions = lib.mkOption { assertions = lib.mkOption {
type = t.listOf t.unspecified; type = types.listOf types.unspecified;
internal = true; internal = true;
visible = false; visible = false;
default = [ ]; default = [ ];
@@ -57,18 +43,18 @@ in
machines = lib.mkOption { machines = lib.mkOption {
default = { }; default = { };
type = t.attrsOf ( type = types.attrsOf (
t.submodule { types.submodule {
options = { options = {
inherit (metaOptions) name description icon; inherit (metaOptions) name description icon;
tags = lib.mkOption { tags = lib.mkOption {
default = [ ]; default = [ ];
apply = lib.unique; apply = lib.unique;
type = t.listOf t.str; type = types.listOf types.str;
}; };
system = lib.mkOption { system = lib.mkOption {
default = null; default = null;
type = t.nullOr t.str; type = types.nullOr types.str;
}; };
}; };
} }
@@ -77,16 +63,16 @@ in
services = lib.mkOption { services = lib.mkOption {
default = { }; default = { };
type = t.attrsOf ( type = types.attrsOf (
t.attrsOf ( types.attrsOf (
t.submodule { types.submodule {
options.meta = metaOptions; options.meta = metaOptions;
options.imports = importsOption; options.imports = importsOption;
options.config = moduleConfig; options.config = moduleConfig;
options.machines = lib.mkOption { options.machines = lib.mkOption {
default = { }; default = { };
type = t.attrsOf ( type = types.attrsOf (
t.submodule { types.submodule {
options.imports = importsOption; options.imports = importsOption;
options.config = moduleConfig; options.config = moduleConfig;
} }
@@ -94,16 +80,16 @@ in
}; };
options.roles = lib.mkOption { options.roles = lib.mkOption {
default = { }; default = { };
type = t.attrsOf ( type = types.attrsOf (
t.submodule { types.submodule {
options.machines = lib.mkOption { options.machines = lib.mkOption {
default = [ ]; default = [ ];
type = t.listOf machineRef; type = types.listOf types.str;
}; };
options.tags = lib.mkOption { options.tags = lib.mkOption {
default = [ ]; default = [ ];
apply = lib.unique; apply = lib.unique;
type = t.listOf tagRef; type = types.listOf types.str;
}; };
options.config = moduleConfig; options.config = moduleConfig;
options.imports = importsOption; options.imports = importsOption;