diff --git a/lib/generators.nix b/lib/generators.nix index abd237eb7d3..800ef5be4fc 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -227,7 +227,7 @@ rec { else "{ " + libStr.concatStringsSep " " (libAttr.mapAttrsToList (name: value: - "${toPretty args name} = ${toPretty args value};") v) + "${libStr.escapeNixIdentifier name} = ${toPretty args value};") v) + " }" else if isFunction v then let fna = lib.functionArgs v; diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix index b066f577f32..7d7380e8b74 100644 --- a/lib/tests/misc.nix +++ b/lib/tests/misc.nix @@ -469,7 +469,7 @@ runTests { function = "<λ>"; functionArgs = "<λ:{(arg),foo}>"; list = "[ 3 4 ${function} [ false ] ]"; - attrs = "{ \"foo\" = null; \"foo bar\" = \"baz\"; }"; + attrs = "{ foo = null; \"foo bar\" = \"baz\"; }"; drv = "<δ:test>"; }; };