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

lib.generators.toPlist: add floats #42938

Merged
merged 1 commit into from Jul 3, 2018

Conversation

matthewbauer
Copy link
Member

@matthewbauer matthewbauer commented Jul 3, 2018

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

@matthewbauer matthewbauer requested review from Profpatsch and LnL7 and removed request for edolstra, nbp and Profpatsch July 3, 2018 20:04
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
Copy link
Member

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
Copy link
Member

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.

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>";
Copy link
Member

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.

Copy link
Member Author

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.
@matthewbauer matthewbauer merged commit 75a1104 into NixOS:master Jul 3, 2018
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

3 participants