diff --git a/lib/options.nix b/lib/options.nix index 9446eca36778..01160b48ec01 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -127,7 +127,20 @@ rec { /* Helper functions. */ - showOption = concatStringsSep "."; + + # Convert an option, described as a list of the option parts in to a + # safe, human readable version. ie: + # + # (showOption ["foo" "bar" "baz"]) == "foo.bar.baz" + # (showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux" + showOption = parts: let + escapeOptionPart = part: + let + escaped = lib.strings.escapeNixString part; + in if escaped == "\"${part}\"" + then part + else escaped; + in (concatStringsSep ".") (map escapeOptionPart parts); showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files); unknownModule = "";