forked from Fediversity/Fediversity
move inline recursiveAttrs to lib.types
This commit is contained in:
parent
cb8363ebb5
commit
6e3bd814f1
|
@ -128,6 +128,15 @@ rec {
|
||||||
);
|
);
|
||||||
|
|
||||||
types = rec {
|
types = rec {
|
||||||
|
# arbitrarily nested attribute set where the leaves are of type `type`
|
||||||
|
# NOTE: this works for anything but attribute sets!
|
||||||
|
recursiveAttrs = type: with lib.types;
|
||||||
|
# NOTE: due to how `either` works, the first match is significant,
|
||||||
|
# so if `type` happens to be an attrset, the typecheck will consider
|
||||||
|
# `type`, not `attrsOf`
|
||||||
|
attrsOf (either type (recursiveAttrs type));
|
||||||
|
|
||||||
|
# collection of unnamed items that can be added to item-wise, i.e. without wrapping the item in a list
|
||||||
collection = elemType:
|
collection = elemType:
|
||||||
let
|
let
|
||||||
unparenthesize = class: class == "noun";
|
unparenthesize = class: class == "noun";
|
||||||
|
|
|
@ -9,19 +9,11 @@ in
|
||||||
imports = lib.nixFiles ./.;
|
imports = lib.nixFiles ./.;
|
||||||
|
|
||||||
options.templates =
|
options.templates =
|
||||||
let
|
|
||||||
# arbitrarily nested attribute set where the leaves are of type `type`
|
|
||||||
recursiveAttrs = type: with types;
|
|
||||||
# NOTE: due to how `either` works, the first match is significant,
|
|
||||||
# so if `type` happens to be an attrset, the typecheck will consider
|
|
||||||
# `type`, not `attrsOf`
|
|
||||||
attrsOf (either type (recursiveAttrs type));
|
|
||||||
in
|
|
||||||
mkOption {
|
mkOption {
|
||||||
description = ''
|
description = ''
|
||||||
Collection of named helper functions for conversion different structured representations which can be rendered to a string
|
Collection of named helper functions for conversion different structured representations which can be rendered to a string
|
||||||
'';
|
'';
|
||||||
type = recursiveAttrs (with types; functionTo (either str attrs));
|
type = with types; recursiveAttrs (functionTo (either str attrs));
|
||||||
};
|
};
|
||||||
|
|
||||||
options.files = mkOption {
|
options.files = mkOption {
|
||||||
|
|
Loading…
Reference in a new issue