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
Conversation
@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. |
There is actually an undocumented (for unknown reasons) |
9c4d9f4
to
b6363e1
Compare
@dezgeg much thanks! created NixOS/nix#1145 |
I think Travis Failure actually looked somewhat relevant… |
This should probably also include the |
Those are used in manual in a special way. Also, fix manual generation.
b6363e1
to
581c497
Compare
@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
which is now correctly rendered (compare https://nixos.org/nixos/manual/options.html#opt-services.xserver.windowManager.2bwm.enable) |
@vcunat |
# 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 |
There was a problem hiding this comment.
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"
.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, of course.
closing as essentially same was already done |
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