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.cc23
1 files changed, 23 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 1ba440522a75..26ae538f29ad 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -6,11 +6,13 @@
 
 #include "libproto/worker.grpc.pb.h"
 #include "libproto/worker.pb.h"
+#include "libstore/derivations.hh"
 #include "libstore/store-api.hh"
 
 namespace nix::daemon {
 
 using ::grpc::Status;
+using ::nix::proto::BuildStatus;
 using ::nix::proto::PathInfo;
 using ::nix::proto::StorePath;
 using ::nix::proto::StorePaths;
@@ -204,6 +206,27 @@ class WorkerServiceImpl final : public WorkerService::Service {
     return Status::OK;
   }
 
+  Status BuildDerivation(
+      grpc::ServerContext* context,
+      const nix::proto::BuildDerivationRequest* request,
+      nix::proto::BuildDerivationResponse* response) override {
+    auto drv_path = request->drv_path().path();
+    store_->assertStorePath(drv_path);
+    auto drv = BasicDerivation::from_proto(&request->derivation(), store_);
+
+    auto build_mode = nix::build_mode_from(request->build_mode());
+    if (!build_mode) {
+      return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
+    }
+
+    auto res = store_->buildDerivation(drv_path, drv, *build_mode);
+
+    response->set_status(res.status_to_proto());
+    response->set_error_message(res.errorMsg);
+
+    return Status::OK;
+  }
+
   Status QueryMissing(grpc::ServerContext* context, const StorePaths* request,
                       nix::proto::QueryMissingResponse* response) override {
     std::set<Path> targets;