diff --git a/lib/options.nix b/lib/options.nix index 40c1af667619f..b069cfc7d4f0b 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -322,10 +322,16 @@ rec { showOption = parts: let escapeOptionPart = part: let - escaped = lib.strings.escapeNixString part; - in if escaped == "\"${part}\"" + # We assume that these are "special values" and not real configuration data. + # If it is real configuration data, it is rendered incorrectly. + specialIdentifiers = [ + "" # attrsOf (submodule {}) + "*" # listOf (submodule {}) + "" # functionTo + ]; + in if builtins.elem part specialIdentifiers then part - else escaped; + else lib.strings.escapeNixIdentifier part; in (concatStringsSep ".") (map escapeOptionPart parts); showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files); diff --git a/lib/tests/modules.sh b/lib/tests/modules.sh index 57d3b5a76cec1..2be9b5835090c 100755 --- a/lib/tests/modules.sh +++ b/lib/tests/modules.sh @@ -302,11 +302,11 @@ checkConfigOutput '^"baz"$' config.value.nested.bar.baz ./types-anything/mk-mods ## types.functionTo checkConfigOutput '^"input is input"$' config.result ./functionTo/trivial.nix checkConfigOutput '^"a b"$' config.result ./functionTo/merging-list.nix -checkConfigError 'A definition for option .fun.\[function body\]. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix +checkConfigError 'A definition for option .fun.. is not of type .string.. Definition values:\n\s*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix checkConfigOutput '^"b a"$' config.result ./functionTo/list-order.nix checkConfigOutput '^"a c"$' config.result ./functionTo/merging-attrs.nix checkConfigOutput '^"a bee"$' config.result ./functionTo/submodule-options.nix -checkConfigOutput '^"fun.\[function body\].a fun.\[function body\].b"$' config.optionsResult ./functionTo/submodule-options.nix +checkConfigOutput '^"fun..a fun..b"$' config.optionsResult ./functionTo/submodule-options.nix # moduleType checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix diff --git a/lib/types.nix b/lib/types.nix index 9b2c5e846ad15..db5ae03d6fe92 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -616,8 +616,8 @@ rec { descriptionClass = "composite"; check = isFunction; merge = loc: defs: - fnArgs: (mergeDefinitions (loc ++ [ "[function body]" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue; - getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "[function body]" ]); + fnArgs: (mergeDefinitions (loc ++ [ "" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue; + getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "" ]); getSubModules = elemType.getSubModules; substSubModules = m: functionTo (elemType.substSubModules m); functor = (defaultFunctor "functionTo") // { wrapped = elemType; }; diff --git a/nixos/lib/make-options-doc/options-to-docbook.xsl b/nixos/lib/make-options-doc/options-to-docbook.xsl index 978d5e2468a83..4a5b004f7fe6d 100644 --- a/nixos/lib/make-options-doc/options-to-docbook.xsl +++ b/nixos/lib/make-options-doc/options-to-docbook.xsl @@ -39,8 +39,8 @@ concat('opt-', translate( attr[@name = 'name']/string/@value, - '*< >[]:', - '_______' + '*< >[]:"', + '________' ))" />