make collection entries more convenient to access

This commit is contained in:
Valentin Gagarin 2024-11-28 09:43:05 +01:00
parent 649cbb69ef
commit f18ae33b2a

View file

@ -34,7 +34,7 @@ in
name = mkOption {
description = "Symbolic name, used as a human-readable identifier";
type = types.str;
default = name;
default = lib.mkDefault name;
};
prefixes = mkOption {
description = ''
@ -52,12 +52,17 @@ in
};
entry = mkOption {
description = "An entry in the collection";
type = types.collection (types.submodule ({
type = with types; collection (submodule ({
imports = [ config.type ];
_module.args.collection = config;
process-locations = ls: with lib; concatMap (l: map (p: "${p}/${l}") config.prefixes) ls;
}));
};
by-name = mkOption {
description = "Entries accessible by symbolic name";
type = with types; attrsOf attrs;
default = with lib; listToAttrs (map (e: { name = e.name; value = e; }) config.entry);
};
};
}));
};