From 63e0d50f16157bd85fc1b3bef87a90792c66dc7c Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Thu, 25 May 2017 19:18:34 +0300 Subject: [PATCH] types: add short docstrings Fixes #26055 --- lib/types.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/types.nix b/lib/types.nix index b06cc9eedaa..50aa6d77085 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -259,6 +259,7 @@ rec { functor = (defaultFunctor name) // { wrapped = elemType; }; }; + # Value of given type but with no merging (i.e. `uniq list`s are not concatenated). uniq = elemType: mkOptionType rec { name = "uniq"; inherit (elemType) description check; @@ -269,6 +270,7 @@ rec { functor = (defaultFunctor name) // { wrapped = elemType; }; }; + # Null or value of ... nullOr = elemType: mkOptionType rec { name = "nullOr"; description = "null or ${elemType.description}"; @@ -285,6 +287,7 @@ rec { functor = (defaultFunctor name) // { wrapped = elemType; }; }; + # A submodule (like typed attribute set). See NixOS manual. submodule = opts: let opts' = toList opts; @@ -316,6 +319,7 @@ rec { }; }; + # A value from a set of allowed ones. enum = values: let show = v: @@ -331,6 +335,7 @@ rec { functor = (defaultFunctor name) // { payload = values; binOp = a: b: unique (a ++ b); }; }; + # Either value of type `t1` or `t2`. either = t1: t2: mkOptionType rec { name = "either"; description = "${t1.description} or ${t2.description}"; @@ -354,6 +359,8 @@ rec { functor = (defaultFunctor name) // { wrapped = [ t1 t2 ]; }; }; + # Either value of type `finalType` or `coercedType`, the latter is + # converted to `finalType` using `coerceFunc`. coercedTo = coercedType: coerceFunc: finalType: assert coercedType.getSubModules == null; mkOptionType rec {