lib/options: Use escapeNixIdentifier for showOption

This commit is contained in:
Silvan Mosberger 2020-03-13 02:45:26 +01:00
parent f9eb3d158a
commit 124cccbe3b
No known key found for this signature in database
GPG key ID: E8F1E9EAD284E17D

View file

@ -193,14 +193,7 @@ rec {
(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);
showOption = parts: concatMapStringsSep "." escapeNixIdentifier parts;
showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);
unknownModule = "<unknown-file>";