@@ -142,12 +142,14 @@ optionalAttrs allowAliases aliases
142142 runCommand name
143143 {
144144 nativeBuildInputs = [ jq ] ;
145- inherit value ;
145+ value = builtins . toJSON value ;
146146 preferLocalBuild = true ;
147147 __structuredAttrs = true ;
148148 }
149149 ''
150- jq .value "$NIX_ATTRS_JSON_FILE" > $out
150+ valuePath="$TMPDIR/value"
151+ printf "%s" "$value" > "$valuePath"
152+ jq . "$valuePath" > $out
151153 ''
152154 ) { } ;
153155
@@ -165,12 +167,14 @@ optionalAttrs allowAliases aliases
165167 runCommand name
166168 {
167169 nativeBuildInputs = [ remarshal_0_17 ] ;
168- inherit value ;
170+ value = builtins . toJSON value ;
169171 preferLocalBuild = true ;
170172 __structuredAttrs = true ;
171173 }
172174 ''
173- json2yaml --unwrap value "$NIX_ATTRS_JSON_FILE" "$out"
175+ valuePath="$TMPDIR/value"
176+ printf "%s" "$value" > "$valuePath"
177+ json2yaml "$valuePath" "$out"
174178 ''
175179 ) { } ;
176180
@@ -188,12 +192,14 @@ optionalAttrs allowAliases aliases
188192 runCommand name
189193 {
190194 nativeBuildInputs = [ remarshal ] ;
191- inherit value ;
195+ value = builtins . toJSON value ;
192196 preferLocalBuild = true ;
193197 __structuredAttrs = true ;
194198 }
195199 ''
196- json2yaml --unwrap value "$NIX_ATTRS_JSON_FILE" "$out"
200+ valuePath="$TMPDIR/value"
201+ printf "%s" "$value" > "$valuePath"
202+ json2yaml "$valuePath" "$out"
197203 ''
198204 ) { } ;
199205
@@ -932,8 +938,8 @@ optionalAttrs allowAliases aliases
932938 python3
933939 black
934940 ] ;
935- imports = value . _imports or [ ] ;
936- value = removeAttrs value [ "_imports" ] ;
941+ imports = builtins . toJSON ( value . _imports or [ ] ) ;
942+ value = builtins . toJSON ( removeAttrs value [ "_imports" ] ) ;
937943 pythonGen = pkgs . writeText "pythonGen" ''
938944 import json
939945 import os
@@ -956,20 +962,26 @@ optionalAttrs allowAliases aliases
956962 else:
957963 return repr(value)
958964
959- with open(os.environ["NIX_ATTRS_JSON_FILE "], "r") as f:
960- attrs = json.load(f)
961- if attrs[" imports"] is not None:
962- for i in attrs[" imports"] :
965+ with open(os.environ["importsPath "], "r") as f:
966+ imports = json.load(f)
967+ if imports is not None:
968+ for i in imports:
963969 print(f"import {i}")
964970 print()
965971
966- for key, value in attrs["value"].items():
972+ with open(os.environ["valuePath"], "r") as f:
973+ for key, value in json.load(f).items():
967974 print(f"{key} = {recursive_repr(value)}")
968975 '' ;
969976 preferLocalBuild = true ;
970977 __structuredAttrs = true ;
971978 }
972979 ''
980+ export importsPath="$TMPDIR/imports"
981+ printf "%s" "$imports" > "$importsPath"
982+ export valuePath="$TMPDIR/value"
983+ printf "%s" "$value" > "$valuePath"
984+ cat "$valuePath"
973985 python3 "$pythonGen" > $out
974986 black $out
975987 ''
@@ -999,21 +1011,23 @@ optionalAttrs allowAliases aliases
9991011 python3Packages . xmltodict
10001012 libxml2Python
10011013 ] ;
1002- inherit value ;
1014+ value = builtins . toJSON value ;
10031015 pythonGen = pkgs . writeText "pythonGen" ''
10041016 import json
10051017 import os
10061018 import xmltodict
10071019
1008- with open(os.environ["NIX_ATTRS_JSON_FILE "], "r") as f:
1009- print(xmltodict.unparse(json.load(f)["value"] , full_document=${
1020+ with open(os.environ["valuePath "], "r") as f:
1021+ print(xmltodict.unparse(json.load(f), full_document=${
10101022 if withHeader then "True" else "False"
10111023 } , pretty=True, indent=" " * 2))
10121024 '' ;
10131025 preferLocalBuild = true ;
10141026 __structuredAttrs = true ;
10151027 }
10161028 ''
1029+ export valuePath="$TMPDIR/value"
1030+ printf "%s" "$value" > "$valuePath"
10171031 python3 "$pythonGen" > $out
10181032 xmllint $out > /dev/null
10191033 ''
0 commit comments