Merge pull request #85241 from LnL7/show-option
Revert "lib/options: Use escapeNixIdentifier for showOption"
This commit is contained in:
commit
9f2463ccdc
@ -191,7 +191,7 @@ rec {
|
|||||||
|
|
||||||
Example:
|
Example:
|
||||||
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
|
||||||
(showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
|
(showOption ["foo" "bar.baz" "tux"]) == "foo.bar.baz.tux"
|
||||||
|
|
||||||
Placeholders will not be quoted as they are not actual values:
|
Placeholders will not be quoted as they are not actual values:
|
||||||
(showOption ["foo" "*" "bar"]) == "foo.*.bar"
|
(showOption ["foo" "*" "bar"]) == "foo.*.bar"
|
||||||
@ -200,13 +200,14 @@ rec {
|
|||||||
Unlike attributes, options can also start with numbers:
|
Unlike attributes, options can also start with numbers:
|
||||||
(showOption ["windowManager" "2bwm" "enable"]) == "windowManager.2bwm.enable"
|
(showOption ["windowManager" "2bwm" "enable"]) == "windowManager.2bwm.enable"
|
||||||
*/
|
*/
|
||||||
showOption = parts:
|
showOption = parts: let
|
||||||
let
|
|
||||||
escapeOptionPart = part:
|
escapeOptionPart = part:
|
||||||
if part == "*" || builtins.match "<.+>" part != null || builtins.match "[a-zA-Z0-9_][a-zA-Z0-9_'-]+" part != null
|
let
|
||||||
|
escaped = lib.strings.escapeNixString part;
|
||||||
|
in if escaped == "\"${part}\""
|
||||||
then part
|
then part
|
||||||
else escapeNixIdentifier part;
|
else escaped;
|
||||||
in concatMapStringsSep "." escapeOptionPart parts;
|
in (concatStringsSep ".") (map escapeOptionPart parts);
|
||||||
showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);
|
showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);
|
||||||
unknownModule = "<unknown-file>";
|
unknownModule = "<unknown-file>";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user