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

Consolidate logic choosing where we can/should build a bit

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.
This commit is contained in:
John Ericson 2025-08-16 14:25:28 -04:00
parent 2ff59ec3e0
commit b57caaa1a2
8 changed files with 140 additions and 94 deletions

View file

@ -0,0 +1,27 @@
#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