Merge pull request #42938 from matthewbauer/add-float-to-plist

lib.generators.toPlist: add floats
This commit is contained in:
Matthew Bauer 2018-07-03 17:14:31 -04:00 committed by GitHub
commit 75a1104b27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 6 deletions

View File

@ -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}";