|
1 | 1 | #include "derivations.hh" |
2 | 2 | #include "downstream-placeholder.hh" |
3 | 3 | #include "error.hh" |
| 4 | +#include "json-utils.hh" |
4 | 5 | #include "store-api.hh" |
5 | 6 | #include "globals.hh" |
6 | 7 | #include "types.hh" |
@@ -1427,6 +1428,7 @@ nlohmann::json Derivation::toJSON(const StoreDirConfig & store) const |
1427 | 1428 | res["builder"] = builder; |
1428 | 1429 | res["args"] = args; |
1429 | 1430 | res["env"] = env; |
| 1431 | + res["options"] = nlohmann::json(options); |
1430 | 1432 |
|
1431 | 1433 | return res; |
1432 | 1434 | } |
@@ -1484,12 +1486,59 @@ Derivation Derivation::fromJSON( |
1484 | 1486 | throw; |
1485 | 1487 | } |
1486 | 1488 |
|
| 1489 | + auto options = valueAt(json, "options"); |
| 1490 | + |
1487 | 1491 | res.platform = getString(valueAt(json, "system")); |
1488 | 1492 | res.builder = getString(valueAt(json, "builder")); |
1489 | 1493 | res.args = getStringList(valueAt(json, "args")); |
1490 | 1494 | res.env = getStringMap(valueAt(json, "env")); |
| 1495 | + res.options = options.get<DerivationOptions>(); |
| 1496 | + |
| 1497 | + return res; |
| 1498 | +} |
| 1499 | + |
| 1500 | +} |
| 1501 | + |
| 1502 | +namespace nlohmann { |
| 1503 | + |
| 1504 | +using namespace nix; |
| 1505 | + |
| 1506 | +DerivationOptions adl_serializer<DerivationOptions>::from_json(const json & json) { |
| 1507 | + DerivationOptions res; |
| 1508 | + |
| 1509 | + res.additionalSandboxProfile = getString(valueAt(json, "additionalSandboxProfile")); |
| 1510 | + res.noChroot = getBoolean(valueAt(json, "noChroot")); |
| 1511 | + res.impureHostDeps = getStringList(valueAt(json, "impureHostDeps")); |
| 1512 | + res.impureEnvVars = getStringList(valueAt(json, "impureEnvVars")); |
| 1513 | + res.allowLocalNetworking = getBoolean(valueAt(json, "allowLocalNetworking")); |
| 1514 | + |
| 1515 | + res.allowedReferences = optionalValueAt(json, "allowedReferences"); |
| 1516 | + res.allowedRequisites = optionalValueAt(json, "allowedRequisites"); |
| 1517 | + res.disallowedReferences = optionalValueAt(json, "disallowedReferences"); |
| 1518 | + res.disallowedRequisites = optionalValueAt(json, "disallowedRequisites"); |
| 1519 | + |
| 1520 | + res.requiredSystemFeatures = getStringList(valueAt(json, "requiredSystemFeatures")); |
| 1521 | + res.preferLocalBuild = getBoolean(valueAt(json, "preferLocalBuild")); |
| 1522 | + res.allowSubstitutes = getBoolean(valueAt(json, "allowSubstitutes")); |
1491 | 1523 |
|
1492 | 1524 | return res; |
1493 | 1525 | } |
1494 | 1526 |
|
| 1527 | +void adl_serializer<DerivationOptions>::to_json(json & json, DerivationOptions o) { |
| 1528 | + json["additionalSandboxProfile"] = o.additionalSandboxProfile; |
| 1529 | + json["noChroot"] = o.noChroot; |
| 1530 | + json["impureHostDeps"] = o.impureHostDeps; |
| 1531 | + json["impureEnvVars"] = o.impureEnvVars; |
| 1532 | + json["allowLocalNetworking"] = o.allowLocalNetworking; |
| 1533 | + |
| 1534 | + json["disallowedReferences"] = o.allowedReferences; |
| 1535 | + json["disallowedRequisites"] = o.allowedRequisites; |
| 1536 | + json["disallowedReferences"] = o.disallowedReferences; |
| 1537 | + json["disallowedRequisites"] = o.disallowedRequisites; |
| 1538 | + |
| 1539 | + json["requiredSystemFeatures"] = o.requiredSystemFeatures; |
| 1540 | + json["preferLocalBuild"] = o.preferLocalBuild; |
| 1541 | + json["allowSubstitutes"] = o.allowSubstitutes; |
| 1542 | +} |
| 1543 | + |
1495 | 1544 | } |
0 commit comments