From 6e3bd814f10ecc95944cb050d1e73dafff73632f Mon Sep 17 00:00:00 2001 From: valentin gagarin Date: Wed, 13 Nov 2024 15:24:41 +0100 Subject: [PATCH] move inline recursiveAttrs to lib.types --- website/lib.nix | 9 +++++++++ website/presentation/default.nix | 10 +--------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/website/lib.nix b/website/lib.nix index 7ada71f..4b6ea34 100644 --- a/website/lib.nix +++ b/website/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/website/presentation/default.nix b/website/presentation/default.nix index 8f74b91..a0d679e 100644 --- a/website/presentation/default.nix +++ b/website/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 {