Change:
doesn't quote attributes containing periods, so the output is identical for e.g. and . Steps to reproduce the behavior: It should return . Instead it returns . It also doesn't include quotes for components containing other non-attribute-valid chars such as spaces. This is more of an aesthetic issue as is unambiguous, though it bothers me. Not quoting components containing periods is a correctness issue. Right now it calls and checks if the output is identical to . It does have comments explaining that it allows options starting with digits, as well as placeholders like <namelib.strings.escapeNixIdentifierlib.strings.escapeNixIdentifier` and then modifying the regex to allow these additional values. My suggestion for such a regex is something like . This way most punctuation and all whitespace will cause quoting but it will still allow and . Alternatively it could be more conservative and only quote for spaces and periods, but it seems more reasonable to me to quote for arbitrary punctuation as well.
Note that my suggested regex takes advantage of the fact that doesn't seem to be unicode-aware, in that succeeds. This seems like a bug, so if Nix ever gains unicode support here, this might have to be modified to explicitly allow either common placeholder chars or just all non-ASCII chars.
This relates to and

Discussion:
showOption = parts: let escapeOptionPart = part: let <del> escaped = lib.strings.escapeNixString part; in if escaped == ""${part}"" </del> <ins> # We assume that these are "special values" and not real configuration data. # If it is real configuration data, it is rendered incorrectly. specialIdentifiers = [ "<name>"          # attrsOf (submodule {}) "*"               # listOf (submodule {}) "<function body>" # functionTo ]; in if builtins.elem part specialIdentifiers </ins> then part <del> else escaped; </del> <ins> else lib.strings.escapeNixIdentifier part; </ins> in (concatStringsSep ".") (map escapeOptionPart parts); showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);

## types.functionTo checkConfigOutput '^"input is input"$' config.result ./functionTo/trivial.nix checkConfigOutput '^"a b"$' config.result ./functionTo/merging-list.nix <del> checkConfigError 'A definition for option .fun.[function body]. is not of type .string.. Definition values:ns*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix </del> <ins> checkConfigError 'A definition for option .fun.<function body>. is not of type .string.. Definition values:ns*- In .*wrong-type.nix' config.result ./functionTo/wrong-type.nix </ins> 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 <del> checkConfigOutput '^"fun.[function body].a fun.[function body].b"$' config.optionsResult ./functionTo/submodule-options.nix </del> <ins> checkConfigOutput '^"fun.<function body>.a fun.<function body>.b"$' config.optionsResult ./functionTo/submodule-options.nix </ins> # moduleType checkConfigOutput '^"a b"$' config.resultFoo ./declare-variants.nix ./define-variant.nix

descriptionClass = "composite"; check = isFunction; merge = loc: defs: <del> fnArgs: (mergeDefinitions (loc ++ [ "[function body]" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue; getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "[function body]" ]); </del> <ins> fnArgs: (mergeDefinitions (loc ++ [ "<function body>" ]) elemType (map (fn: { inherit (fn) file; value = fn.value fnArgs; }) defs)).mergedValue; getSubOptions = prefix: elemType.getSubOptions (prefix ++ [ "<function body>" ]); </ins> getSubModules = elemType.getSubModules; substSubModules = m: functionTo (elemType.substSubModules m); functor = (defaultFunctor "functionTo") // { wrapped = elemType; };

concat('opt-', translate( attr[@name = 'name']/string/@value, <del> '*&lt; >[]:', '_______' </del> <ins> '*&lt; >[]:&quot;', '________' </ins> ))" /> <varlistentry> <term xlink:href="#{$id}">