diff --git a/lib.nix b/lib.nix index 7ada71f8..4b6ea340 100644 --- a/lib.nix +++ b/lib.nix @@ -128,6 +128,15 @@ 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: let unparenthesize = class: class == "noun"; diff --git a/presentation/default.nix b/presentation/default.nix index 8f74b91c..a0d679e6 100644 --- a/presentation/default.nix +++ b/presentation/default.nix @@ -9,19 +9,11 @@ in imports = lib.nixFiles ./.; 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 { description = '' 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 {