@@ -149,7 +149,7 @@ ValidPathInfo ValidPathInfo::makeFromCA(
149149 return res;
150150}
151151
152- nlohmann::json UnkeyedValidPathInfo::toJSON (const StoreDirConfig & store, bool includeImpureInfo) const
152+ nlohmann::json UnkeyedValidPathInfo::toJSON (const StoreDirConfig * store, bool includeImpureInfo) const
153153{
154154 using nlohmann::json;
155155
@@ -163,13 +163,15 @@ nlohmann::json UnkeyedValidPathInfo::toJSON(const StoreDirConfig & store, bool i
163163 {
164164 auto & jsonRefs = jsonObject[" references" ] = json::array ();
165165 for (auto & ref : references)
166- jsonRefs.emplace_back (store. printStorePath (ref));
166+ jsonRefs.emplace_back (store ? static_cast <json>(store-> printStorePath (ref)) : static_cast <json> (ref));
167167 }
168168
169169 jsonObject[" ca" ] = ca;
170170
171171 if (includeImpureInfo) {
172- jsonObject[" deriver" ] = deriver ? (std::optional{store.printStorePath (*deriver)}) : std::nullopt ;
172+ jsonObject[" deriver" ] = deriver ? (store ? static_cast <json>(std::optional{store->printStorePath (*deriver)})
173+ : static_cast <json>(std::optional{*deriver}))
174+ : static_cast <json>(std::optional<StorePath>{});
173175
174176 jsonObject[" registrationTime" ] = registrationTime ? (std::optional{registrationTime}) : std::nullopt ;
175177
@@ -183,7 +185,7 @@ nlohmann::json UnkeyedValidPathInfo::toJSON(const StoreDirConfig & store, bool i
183185 return jsonObject;
184186}
185187
186- UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON (const StoreDirConfig & store, const nlohmann::json & _json)
188+ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON (const StoreDirConfig * store, const nlohmann::json & _json)
187189{
188190 UnkeyedValidPathInfo res{
189191 Hash (Hash::dummy),
@@ -203,7 +205,7 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
203205 try {
204206 auto references = getStringList (valueAt (json, " references" ));
205207 for (auto & input : references)
206- res.references .insert (store. parseStorePath (static_cast < const std::string & >(input) ));
208+ res.references .insert (store ? store-> parseStorePath (getString (input)) : static_cast <StorePath >(input));
207209 } catch (Error & e) {
208210 e.addTrace ({}, " while reading key 'references'" );
209211 throw ;
@@ -218,7 +220,7 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
218220
219221 if (auto * rawDeriver0 = optionalValueAt (json, " deriver" ))
220222 if (auto * rawDeriver = getNullable (*rawDeriver0))
221- res.deriver = store. parseStorePath (getString (*rawDeriver));
223+ res.deriver = store ? store-> parseStorePath (getString (*rawDeriver)) : static_cast <StorePath>(*rawDeriver );
222224
223225 if (auto * rawRegistrationTime0 = optionalValueAt (json, " registrationTime" ))
224226 if (auto * rawRegistrationTime = getNullable (*rawRegistrationTime0))
@@ -234,3 +236,19 @@ UnkeyedValidPathInfo UnkeyedValidPathInfo::fromJSON(const StoreDirConfig & store
234236}
235237
236238} // namespace nix
239+
240+ namespace nlohmann {
241+
242+ using namespace nix ;
243+
244+ UnkeyedValidPathInfo adl_serializer<UnkeyedValidPathInfo>::from_json(const json & json)
245+ {
246+ return UnkeyedValidPathInfo::fromJSON (nullptr , json);
247+ }
248+
249+ void adl_serializer<UnkeyedValidPathInfo>::to_json(json & json, const UnkeyedValidPathInfo & c)
250+ {
251+ json = c.toJSON (nullptr , true );
252+ }
253+
254+ } // namespace nlohmann
0 commit comments