summaryrefslogtreecommitdiffstats
path: root/lib/generators.nix
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-09-04 17:23:28 +0200
committerSilvan Mosberger <contact@infinisil.com>2020-09-17 18:20:18 +0200
commit4811f54e94756d8a83ee9fb439e56675033923ae (patch)
tree1dcb98192c03f230855ab75bd37285a0b178f6c7 /lib/generators.nix
parent0f6231702fc1ccde0130bcbf297ff415d17b06d8 (diff)
lib/generators.toPretty: Wrap in a go function
As a preparation to the following commit
Diffstat (limited to 'lib/generators.nix')
-rw-r--r--lib/generators.nix7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/generators.nix b/lib/generators.nix
index 800ef5be4fcd..e6b9b6b66c8b 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -204,7 +204,7 @@ rec {
will use fn to convert val to a pretty printed representation.
(This means fn is type Val -> String.) */
allowPrettyValues ? false
- }@args: v: with builtins;
+ }@args: let go = v: with builtins;
let isPath = v: typeOf v == "path";
in if isInt v then toString v
else if isFloat v then "~${toString v}"
@@ -214,7 +214,7 @@ rec {
else if null == v then "null"
else if isPath v then toString v
else if isList v then "[ "
- + libStr.concatMapStringsSep " " (toPretty args) v
+ + libStr.concatMapStringsSep " " go v
+ " ]"
else if isAttrs v then
# apply pretty values if allowed
@@ -227,7 +227,7 @@ rec {
else "{ "
+ libStr.concatStringsSep " " (libAttr.mapAttrsToList
(name: value:
- "${libStr.escapeNixIdentifier name} = ${toPretty args value};") v)
+ "${libStr.escapeNixIdentifier name} = ${go value};") v)
+ " }"
else if isFunction v then
let fna = lib.functionArgs v;
@@ -237,6 +237,7 @@ rec {
in if fna == {} then "<λ>"
else "<λ:{${showFnas}}>"
else abort "generators.toPretty: should never happen (v = ${v})";
+ in go;
# PLIST handling
toPlist = {}: v: let