mirror of
https://github.com/NixOS/nix.git
synced 2025-11-21 17:59:36 +01:00
I want to separate "policy" from "mechanism". Now the logic to decide how to build (a policy choice, though with some hard constraints) is all in derivation building goal, and all in the same spot. build hook, external builder, or local builder --- the choice between all three is made in the same spot --- pure policy. Now, if you want to use the external deriation builder, you simply provide the `ExternalBuilder` you wish to use, and there is no additional checking --- pure mechanism. It is the responsibility of the caller to choose an external builder that works for the derivation in question. Also, `checkSystem()` was the only thing throwing `BuildError` from `startBuilder`. Now that that is gone, we can now remove the `try...catch` around that.
27 lines
618 B
C++
27 lines
618 B
C++
#include "nix/util/json-utils.hh"
|
|
#include "nix/store/build/derivation-builder.hh"
|
|
|
|
namespace nlohmann {
|
|
|
|
using namespace nix;
|
|
|
|
ExternalBuilder adl_serializer<ExternalBuilder>::from_json(const json & json)
|
|
{
|
|
auto obj = getObject(json);
|
|
return {
|
|
.systems = valueAt(obj, "systems"),
|
|
.program = valueAt(obj, "program"),
|
|
.args = valueAt(obj, "args"),
|
|
};
|
|
}
|
|
|
|
void adl_serializer<ExternalBuilder>::to_json(json & json, const ExternalBuilder & eb)
|
|
{
|
|
json = {
|
|
{"systems", eb.systems},
|
|
{"program", eb.program},
|
|
{"args", eb.args},
|
|
};
|
|
}
|
|
|
|
} // namespace nlohmann
|