about summary refs log tree commit diff
path: root/third_party/nix/src/nix-daemon
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/nix-daemon')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
index b7d5836091af..cbc5452a7177 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -1,7 +1,9 @@
 #include "nix-daemon-proto.hh"
 
 #include <filesystem>
+#include <ostream>
 #include <sstream>
+#include <streambuf>
 #include <string>
 
 #include <absl/strings/str_cat.h>
@@ -92,6 +94,22 @@ struct RetrieveRegularNARSink : ParseSink {
                   absl::StrFormat("path '%s' is not in the Nix store", path)); \
   }
 
+class BuildLogStreambuf final : public std::streambuf {
+ public:
+  using Writer = grpc::ServerWriter<nix::proto::BuildEvent>;
+  explicit BuildLogStreambuf(Writer* writer) : writer_(writer) {}
+
+  std::streamsize xsputn(const char_type* s, std::streamsize n) override {
+    nix::proto::BuildEvent event;
+    event.mutable_build_log()->set_line(s, n);
+    writer_->Write(event);
+    return n;
+  }
+
+ private:
+  Writer* writer_{};
+};
+
 class WorkerServiceImpl final : public WorkerService::Service {
  public:
   WorkerServiceImpl(nix::Store& store) : store_(&store) {}