aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/build
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/build')
-rw-r--r--src/libstore/build/derivation-goal.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/src/libstore/build/derivation-goal.cc b/src/libstore/build/derivation-goal.cc
index 01643605f..dadaccbcf 100644
--- a/src/libstore/build/derivation-goal.cc
+++ b/src/libstore/build/derivation-goal.cc
@@ -1340,9 +1340,26 @@ void DerivationGoal::handleChildOutput(int fd, std::string_view data)
auto s = handleJSONLogMessage(*json, worker.act, hook->activities, true);
// ensure that logs from a builder using `ssh-ng://` as protocol
// are also available to `nix log`.
- if (s && !isWrittenToLog && logSink && (*json)["type"] == resBuildLogLine) {
- auto f = (*json)["fields"];
- (*logSink)((f.size() > 0 ? f.at(0).get<std::string>() : "") + "\n");
+ if (s && !isWrittenToLog && logSink) {
+ const auto type = (*json)["type"];
+ const auto fields = (*json)["fields"];
+ if (type == resBuildLogLine) {
+ (*logSink)((fields.size() > 0 ? fields[0].get<std::string>() : "") + "\n");
+ } else if (type == resSetPhase && ! fields.is_null()) {
+ const auto phase = fields[0];
+ if (! phase.is_null()) {
+ // nixpkgs' stdenv produces lines in the log to signal
+ // phase changes.
+ // We want to get the same lines in case of remote builds.
+ // The format is:
+ // @nix { "action": "setPhase", "phase": "$curPhase" }
+ const auto logLine = nlohmann::json::object({
+ {"action", "setPhase"},
+ {"phase", phase}
+ });
+ (*logSink)("@nix " + logLine.dump(-1, ' ', false, nlohmann::json::error_handler_t::replace) + "\n");
+ }
+ }
}
}
currentHookLine.clear();