1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 01:39:36 +01:00

Allow for standard nlohmann JSON serializers to take separate XP features

I realized that we can actually do this thing, even though it is not
what nlohmann expects at all, because the extra parameter has a default
argument so nlohmann doesn't need to care. Sneaky!
This commit is contained in:
John Ericson 2025-10-16 15:49:47 -04:00
parent d87a06af7a
commit 1c02dd5b9c
5 changed files with 35 additions and 32 deletions

View file

@ -1496,9 +1496,10 @@ namespace nlohmann {
using namespace nix;
DerivationOutput adl_serializer<DerivationOutput>::from_json(const json & json)
DerivationOutput
adl_serializer<DerivationOutput>::from_json(const json & json, const ExperimentalFeatureSettings & xpSettings)
{
return DerivationOutput::fromJSON(json);
return DerivationOutput::fromJSON(json, xpSettings);
}
void adl_serializer<DerivationOutput>::to_json(json & json, const DerivationOutput & c)
@ -1506,9 +1507,9 @@ void adl_serializer<DerivationOutput>::to_json(json & json, const DerivationOutp
json = c.toJSON();
}
Derivation adl_serializer<Derivation>::from_json(const json & json)
Derivation adl_serializer<Derivation>::from_json(const json & json, const ExperimentalFeatureSettings & xpSettings)
{
return Derivation::fromJSON(json);
return Derivation::fromJSON(json, xpSettings);
}
void adl_serializer<Derivation>::to_json(json & json, const Derivation & c)

View file

@ -537,5 +537,5 @@ std::string hashPlaceholder(const OutputNameView outputName);
} // namespace nix
JSON_IMPL(nix::DerivationOutput)
JSON_IMPL(nix::Derivation)
JSON_IMPL_WITH_XP_FEATURES(nix::DerivationOutput)
JSON_IMPL_WITH_XP_FEATURES(nix::Derivation)