Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module system: better option pretty-printing (add quotes when necessary) #20839

Closed
wants to merge 2 commits into from

Conversation

danbst
Copy link
Contributor

@danbst danbst commented Dec 1, 2016

Fixes #18764

Because of lack or regexps in Nix, the implementation is larger than expected. I'm open to suggestions on how to simplify it

@mention-bot
Copy link

@danbst, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @nbp and @ericsagnes to be potential reviewers.

@dezgeg
Copy link
Contributor

dezgeg commented Dec 1, 2016

There is actually an undocumented (for unknown reasons) builtins.match that's already used in nixpkgs.

@danbst
Copy link
Contributor Author

danbst commented Dec 3, 2016

@dezgeg much thanks! created NixOS/nix#1145

@7c6f434c
Copy link
Member

I think Travis Failure actually looked somewhat relevant…

@lheckemann
Copy link
Member

This should probably also include the . character in the regex? Would be nice if we could get this merged after fixing the manual rendering.

@danbst
Copy link
Contributor Author

danbst commented Feb 25, 2018

@lheckemann thanks for the ping! I've fixed the manual build and rebased on top of master

Out of added goodies, found there exist a sole option

services.xserver.windowManager."2bwm".enable

which is now correctly rendered (compare https://nixos.org/nixos/manual/options.html#opt-services.xserver.windowManager.2bwm.enable)

@danbst
Copy link
Contributor Author

danbst commented Apr 4, 2018

@vcunat
re 2bwm - you may be interested in this PR too

# https://github.com/NixOS/nix/blob/a5e761dddb6b090b233aebe29dc30ebfbc058dab/src/libexpr/lexer.l#L87
quotesWhenNeeded = x:
if x == "<name>" || x == "<name?>" || x == "*" # special cases needed for documentation
|| builtins.match ''[a-zA-Z\_][a-zA-Z0-9\_\'\-]*'' x != null
Copy link
Member

Choose a reason for hiding this comment

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

Maybe add "." here? While there are no stock options that this would affect, option attr paths do sometimes have .s in them, e.g. services.nginx.virtualHosts."www.example.com".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This regex should be treated inverted - matched shouldn't be enclosed in double quotes

Copy link
Member

Choose a reason for hiding this comment

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

oh, of course.

@danbst
Copy link
Contributor Author

danbst commented Jun 24, 2018

closing as essentially same was already done
#36344

@danbst danbst closed this Jun 24, 2018
@danbst danbst deleted the fix-show-option branch April 15, 2019 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants