From 1bb4cb9c6c334a6d52755066b1747547da137b00 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 31 May 2024 19:19:48 +0100 Subject: [PATCH] lib/options: add `mkAttrsOf'` & `mkListOf'` (etc) --- lib/options.nix | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/options.nix b/lib/options.nix index 632642dc38..b1152eacf0 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -171,9 +171,22 @@ rec { default: assert default == null || isString default; mkNullableWithRaw types.str (generators.toPretty { } default); - mkAttributeSet = mkNullable nixvimTypes.attrs; - mkListOf = ty: default: mkNullable (with nixvimTypes; listOf (maybeRaw ty)) default; - mkAttrsOf = ty: default: mkNullable (with nixvimTypes; attrsOf (maybeRaw ty)) default; + + mkAttributeSet' = args: mkNullable' (args // { type = nixvimTypes.attrs; }); + mkAttributeSet = default: description: mkAttributeSet' { inherit default description; }; + + mkListOf' = + { type, ... }@args: mkNullable' (args // { type = with nixvimTypes; listOf (maybeRaw type); }); + mkListOf = + type: default: description: + mkListOf' { inherit type default description; }; + + mkAttrsOf' = + { type, ... }@args: mkNullable' (args // { type = with nixvimTypes; attrsOf (maybeRaw type); }); + mkAttrsOf = + type: default: description: + mkAttrsOf' { inherit type default description; }; + mkEnum = enumValues: default: mkNullableWithRaw (types.enum enumValues) (