mirror of
https://github.com/NixOS/nix.git
synced 2025-11-11 21:16:02 +01:00
external-derivation-builder: write the json doc into builder's stdin
This commit is contained in:
parent
804729b4ec
commit
d1f57c5dae
2 changed files with 13 additions and 6 deletions
|
|
@ -1248,7 +1248,7 @@ public:
|
|||
R"(
|
||||
Helper programs that execute derivations.
|
||||
|
||||
The program is passed a JSON document that describes the build environment as the final argument.
|
||||
The program is passed a JSON document that describes the build environment on standard input.
|
||||
The JSON document looks like this:
|
||||
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,11 @@ struct ExternalDerivationBuilder : DerivationBuilderImpl
|
|||
{
|
||||
Settings::ExternalBuilder externalBuilder;
|
||||
|
||||
/**
|
||||
* Pipe for talking to the spawned builder.
|
||||
*/
|
||||
Pipe toBuilder;
|
||||
|
||||
ExternalDerivationBuilder(
|
||||
Store & store,
|
||||
std::unique_ptr<DerivationBuilderCallbacks> miscMethods,
|
||||
|
|
@ -83,23 +88,22 @@ struct ExternalDerivationBuilder : DerivationBuilderImpl
|
|||
json.emplace("realStoreDir", getLocalStore(store).config->realStoreDir.get());
|
||||
json.emplace("system", drv.platform);
|
||||
|
||||
// FIXME: maybe write this JSON into the builder's stdin instead....?
|
||||
auto jsonFile = topTmpDir + "/build.json";
|
||||
writeFile(jsonFile, json.dump());
|
||||
toBuilder.create();
|
||||
|
||||
pid = startProcess([&]() {
|
||||
openSlave();
|
||||
try {
|
||||
commonChildInit();
|
||||
|
||||
if (dup2(toBuilder.readSide.get(), STDIN_FILENO) == -1)
|
||||
throw SysError("duping to-builder read side to builder's stdin");
|
||||
|
||||
Strings args = {externalBuilder.program};
|
||||
|
||||
if (!externalBuilder.args.empty()) {
|
||||
args.insert(args.end(), externalBuilder.args.begin(), externalBuilder.args.end());
|
||||
}
|
||||
|
||||
args.insert(args.end(), jsonFile);
|
||||
|
||||
debug("executing external builder: %s", concatStringsSep(" ", args));
|
||||
execv(externalBuilder.program.c_str(), stringsToCharPtrs(args).data());
|
||||
|
||||
|
|
@ -109,6 +113,9 @@ struct ExternalDerivationBuilder : DerivationBuilderImpl
|
|||
_exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
writeFull(toBuilder.writeSide.get(), json.dump());
|
||||
toBuilder.close();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue