Skip to content

Commit

Permalink
lib/options: Relax showOption quoting
Browse files Browse the repository at this point in the history
124cccb
broke the build of NixOS manual.

It does not make sense to be as strict as with attributes since we
are not limited by the CLI's inability to handle numbers.
Placeholders should not be quoted either as they are not part of Nix
syntax but a meta-level construct.
  • Loading branch information
jtojnar committed Apr 14, 2020
1 parent 1ca2475 commit c652b64
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/options.nix
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,21 @@ rec {
Example:
(showOption ["foo" "bar" "baz"]) == "foo.bar.baz"
(showOption ["foo" "bar.baz" "tux"]) == "foo.\"bar.baz\".tux"
Placeholders will not be quoted as they are not actual values:
(showOption ["foo" "*" "bar"]) == "foo.*.bar"
(showOption ["foo" "<name>" "bar"]) == "foo.<name>.bar"
Unlike attributes, options can also start with numbers:
(showOption ["windowManager" "2bwm" "enable"]) == "windowManager.2bwm.enable"
*/
showOption = parts: concatMapStringsSep "." escapeNixIdentifier parts;
showOption = parts:
let
escapeOptionPart = part:
if part == "*" || builtins.match "<.+>" part != null || builtins.match "[a-zA-Z0-9_][a-zA-Z0-9_'-]+" part != null
then part
else escapeNixIdentifier part;
in concatMapStringsSep "." escapeOptionPart parts;
showFiles = files: concatStringsSep " and " (map (f: "`${f}'") files);
unknownModule = "<unknown-file>";

Expand Down

1 comment on commit c652b64

@jtojnar
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/CLI/Bash

Please sign in to comment.