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.generators.toPlist: add floats #42938
Conversation
if isAttrs x then attrs ind x else | ||
if isList x then list ind x else | ||
if isAttrs x then attrs ind x else | ||
if isFloat x then float ind x else |
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.
builtins.isFloat
was not available in 1.11 and we should keep nixpkgs compatible until 18.09. But we can add a fallback as long as nothing in nixpkgs itself uses floats.
eg.
let
toFloat = builtins.toFloat or (_: false);
...
@@ -177,13 +177,14 @@ rec { | |||
|
|||
# PLIST handling | |||
toPlist = {}: v: let |
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.
Guess it's a bit late, but I kind of disagree with the casing plist is an acronym. It should be toPLIST
and toPropertyList
IMHO.
ba40373
to
da87cb1
Compare
lib/generators.nix
Outdated
abort "generators.toPlist: should never happen (v = ${v})"; | ||
|
||
literal = ind: x: ind + x; | ||
|
||
bool = ind: x: literal ind (if x then "<true/>" else "<false/>"); | ||
int = ind: x: literal ind "<integer>${toString x}</integer>"; |
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'm pretty sure this is necessary, same with floats.
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.
Really? I'll see what happens but I thought that ${} would convert it to a string automatically.
Nix now supports floats & we can pretty easily map them to Plist’s <real></real> type. Note that I am unsure how this affects older version of Nix that may or may not have builtins.isFloat available. Make sure this satisfies minver.nix’s "1.11" requirement.
da87cb1
to
dc72e8a
Compare
Nix now supports floats & we can pretty easily map them to Plist’s
type. Note that I am unsure how this affects older
version of Nix that may or may not have builtins.isFloat available.
Make sure this satisfies minver.nix’s "1.11" requirement.
/cc @3noch