diff options
author | Matthew Bauer <mjbauer95@gmail.com> | 2018-07-03 12:24:54 -0400 |
---|---|---|
committer | Matthew Bauer <mjbauer95@gmail.com> | 2018-07-03 17:14:00 -0400 |
commit | dc72e8ac06146f3a9c364628274e5bd4ecfc9221 (patch) | |
tree | ccb443270cd45dc2481f283776a44e6e9808a045 /lib | |
parent | d12e7b8d17608bb4415c197eb1c12593cd31b9d2 (diff) | |
download | nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.tar nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.tar.gz nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.tar.bz2 nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.tar.lz nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.tar.xz nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.tar.zst nixlib-dc72e8ac06146f3a9c364628274e5bd4ecfc9221.zip |
lib.generators.toPlist: add floats
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/generators.nix | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/generators.nix b/lib/generators.nix index 073bb6982e14..aa6759087031 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 "<integer>${toString x}</integer>"; str = ind: x: literal ind "<string>${x}</string>"; key = ind: x: literal ind "<key>${x}</key>"; + float = ind: x: literal ind "<real>${toString x}</real>"; indent = ind: expr "\t${ind}"; |