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 b7d583609..cbc5452a7 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 +#include #include +#include #include #include @@ -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; + 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) {}