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
lib/types: enhances separatedString's description. #48251
lib/types: enhances separatedString's description. #48251
Conversation
lib/types.nix
Outdated
@@ -194,7 +194,10 @@ rec { | |||
# separator between the values). | |||
separatedString = sep: mkOptionType rec { | |||
name = "separatedString"; | |||
description = "string"; | |||
description = if sep == "" | |||
then "string" # for types.string. |
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 description is still misleading because it is the same description as lib.types.str
, which is the preferred (non-deprecated) string type. I think the else branch can work for all cases! Should we put \"
around the separator?
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.
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.
I know the description for types.string
is misleading: I do not know what it should be. I'm thinking "String concatenated with ''" is too clunky. Maybe "Concatenated string" would be better.
The separator is JSON-encoded, which also adds quotes around the string.
(nix-repl adds more escaping)
nix-repl> builtins.toJSON ""
"\"\""
nix-repl> builtins.toJSON "\n"
"\"\\n\""
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.
What about "Concatenated string (deprecated)"?
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.
@ryantm The fact that it's deprecated shouldn't be part of the description, which might end up in the docs or so.
I like "Concatenated string" for the sep == ""
case.
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.
Updated without the "deprecated" bit; its deprecation isn't really a part of its description imho (even though it is deprecated). The end-user, using the module, cannot do anything about the deprecation notice there.
0fb4190
to
d636625
Compare
@samueldr Looks good! Your nice commit message isn't quite right anymore. |
The previous description "string" is misleading in the full options manual pages; they are actually concatenated strings, with a specific character. The empty string version ("types.string") has been special-cased to provide a better message.
d636625
to
0808c7c
Compare
Thanks, missed that bit! |
@GrahamcOfBorg test nghttpx |
Success on x86_64-linux (full log) Attempted: tests.nghttpx Partial log (click to expand)
|
Success on aarch64-linux (full log) Attempted: tests.nghttpx Partial log (click to expand)
|
Backported [release-18.09 03bf8cd] lib/types: enhances separatedString's description |
The previous description "string" is misleading in the full options
manual pages; they are actually concatenated strings, with a specific
character.
The string
""
has been documented to stay coherent with the previouslydeprecated "types.string".
Motivation for this change
This is for nixos-homepage/pull/246, where @ryantm was curious about listing the type descriptions on the options page. The particular type desired had to be fixed to be more useful (I think).
To be useful for nixos-homepage, it would need to be backported to 18.09.
Things done
sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)nix path-info -S
before and after)