From 4d101993bfed0a40caf5e1aaa19cc085f2c7192a Mon Sep 17 00:00:00 2001 From: Thomas Bach Date: Sun, 10 Sep 2017 08:50:07 +0800 Subject: [PATCH] manual: reworked submodule section for better readability The section was strange to read, as the initial example already used `listOf' which is mentioned in the very first paragraph. Then you read in a subsection about `listOf' and the exact same example is given once again. --- nixos/doc/manual/development/option-types.xml | 59 ++++++++++--------- 1 file changed, 30 insertions(+), 29 deletions(-) diff --git a/nixos/doc/manual/development/option-types.xml b/nixos/doc/manual/development/option-types.xml index b8e3ea774a71..7b86e518aaf1 100644 --- a/nixos/doc/manual/development/option-types.xml +++ b/nixos/doc/manual/development/option-types.xml @@ -157,26 +157,26 @@
Submodule - Submodule is a very powerful type that defines a set of sub-options that - are handled like a separate module. - It is especially interesting when used with composed types like - attrsOf or listOf. + submodule is a very powerful type that defines a set + of sub-options that are handled like a separate module. - The submodule type take a parameter o, that - should be a set, or a function returning a set with an - options key defining the sub-options. - The option set can be defined directly () or as reference (). + It takes a parameter o, that should be a set, + or a function returning a set with an options key + defining the sub-options. + Submodule option definitions are type-checked accordingly to the + options declarations. + Of course, you can nest submodule option definitons for even higher + modularity. - Submodule option definitions are type-checked accordingly to the options - declarations. It is possible to declare submodule options inside a submodule - sub-options for even higher modularity. + The option set can be defined directly + () or as reference + (). Directly defined submodule options.mod = mkOption { description = "submodule example"; - type = with types; listOf (submodule { + type = with types; submodule { options = { foo = mkOption { type = int; @@ -185,10 +185,10 @@ options.mod = mkOption { type = str; }; }; - }); + }; }; -Submodule defined as a +<example xml:id='ex-submodule-reference'><title>Submodule defined as a reference let @@ -205,16 +205,20 @@ let in options.mod = mkOption { description = "submodule example"; - type = with types; listOf (submodule modOptions); + type = with types; submodule modOptions; }; -
Composed with <literal>listOf</literal> - - When composed with listOf, submodule allows multiple - definitions of the submodule option set. + The submodule type is especially interesting when + used with composed types like attrsOf or + listOf. + When composed with listOf + (), + submodule allows multiple definitions of the submodule + option set (). + Declaration of a list - of submodules + nof submodules options.mod = mkOption { description = "submodule example"; @@ -238,13 +242,11 @@ config.mod = [ { foo = 2; bar = "two"; } ]; -
- - -
Composed with <literal>attrsOf</literal> - - When composed with attrsOf, submodule allows multiple - named definitions of the submodule option set. + When composed with attrsOf + (), + submodule allows multiple named definitions of the + submodule option set (). + Declaration of attribute sets of submodules @@ -269,7 +271,6 @@ options.mod = mkOption { config.mod.one = { foo = 1; bar = "one"; }; config.mod.two = { foo = 2; bar = "two"; }; -
Extending types