From dc72e8ac06146f3a9c364628274e5bd4ecfc9221 Mon Sep 17 00:00:00 2001 From: Matthew Bauer Date: Tue, 3 Jul 2018 12:24:54 -0400 Subject: [PATCH] lib.generators.toPlist: add floats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- lib/generators.nix | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/generators.nix b/lib/generators.nix index 073bb6982e1..aa675908703 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -177,13 +177,15 @@ rec { # PLIST handling toPlist = {}: v: let - expr = ind: x: with builtins; - if isNull x then "" else - if isBool x then bool ind x else - if isInt x then int ind x else + isFloat = builtins.isFloat or (x: false); + expr = ind: x: with builtins; + if isNull x then "" else + if isBool x then bool ind x else + if isInt x then int ind x else if isString x then str ind x else - if isList x then list ind x else - 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 abort "generators.toPlist: should never happen (v = ${v})"; literal = ind: x: ind + x; @@ -192,6 +194,7 @@ rec { int = ind: x: literal ind "${toString x}"; str = ind: x: literal ind "${x}"; key = ind: x: literal ind "${x}"; + float = ind: x: literal ind "${toString x}"; indent = ind: expr "\t${ind}";