forked from Fediversity/Fediversity
make collection entries more convenient to access
This commit is contained in:
parent
649cbb69ef
commit
f18ae33b2a
|
@ -34,7 +34,7 @@ in
|
||||||
name = mkOption {
|
name = mkOption {
|
||||||
description = "Symbolic name, used as a human-readable identifier";
|
description = "Symbolic name, used as a human-readable identifier";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = name;
|
default = lib.mkDefault name;
|
||||||
};
|
};
|
||||||
prefixes = mkOption {
|
prefixes = mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
|
@ -52,12 +52,17 @@ in
|
||||||
};
|
};
|
||||||
entry = mkOption {
|
entry = mkOption {
|
||||||
description = "An entry in the collection";
|
description = "An entry in the collection";
|
||||||
type = types.collection (types.submodule ({
|
type = with types; collection (submodule ({
|
||||||
imports = [ config.type ];
|
imports = [ config.type ];
|
||||||
_module.args.collection = config;
|
_module.args.collection = config;
|
||||||
process-locations = ls: with lib; concatMap (l: map (p: "${p}/${l}") config.prefixes) ls;
|
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);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue