Merge pull request #36344 from grahamc/fancy-option-names

lib/options: teach showOptions about funny option names
This commit is contained in:
Graham Christensen 2018-05-25 20:55:17 -04:00 committed by GitHub
commit 951e9099c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 = "<unknown-file>";