about summary refs log tree commit diff
path: root/third_party/nix/src/nix-daemon
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-02T00·23-0400
committerglittershark <grfn@gws.fyi>2020-08-03T17·32+0000
commit209489e348904aa2e2cddc64340ea44ab3074dfd (patch)
treeaa51897d25f6e9ff86a53a41f72f0c8bc3d104e5 /third_party/nix/src/nix-daemon
parent8a1c7da357873a645405c0f5b8cc75d751dedb83 (diff)
feat(3p/nix): Implement two more RPC calls r/1567
Implement AddTextToStore and BuildPaths both on the client and the
server

Refs: #29
Change-Id: I45294c3e1c1a7489e42099d36425b7acc04e0427
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1560
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/nix-daemon')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc36
1 files changed, 35 insertions, 1 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 63c68ed1e5b1..bf65dd315d00 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -172,6 +172,40 @@ class WorkerServiceImpl final : public WorkerService::Service {
     return Status::OK;
   }
 
+  Status AddTextToStore(grpc::ServerContext*,
+                        const nix::proto::AddTextToStoreRequest* request,
+                        nix::proto::StorePath* response) override {
+    PathSet references;
+    for (const auto& ref : request->references()) {
+      references.insert(ref);
+    }
+    auto path =
+        store_->addTextToStore(request->name(), request->content(), references);
+    response->set_path(path);
+    return Status::OK;
+  }
+
+  Status BuildPaths(grpc::ServerContext*,
+                    const nix::proto::BuildPathsRequest* request,
+                    google::protobuf::Empty*) override {
+    PathSet drvs;
+    for (const auto& drv : request->drvs()) {
+      drvs.insert(drv);
+    }
+    auto mode = BuildModeFrom(request->mode());
+
+    if (!mode.has_value()) {
+      return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
+    }
+
+    // TODO(grfn): If mode is repair and not trusted, we need to return an error
+    // here (but we can't yet because we don't know anything about trusted
+    // users)
+    store_->buildPaths(drvs, mode.value());
+
+    return Status::OK;
+  }
+
   Status QuerySubstitutablePathInfos(
       grpc::ServerContext*, const StorePaths* request,
       nix::proto::SubstitutablePathInfos* response) override {
@@ -357,7 +391,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
     store_->assertStorePath(drv_path);
     auto drv = BasicDerivation::from_proto(&request->derivation(), *store_);
 
-    auto build_mode = nix::build_mode_from(request->build_mode());
+    auto build_mode = nix::BuildModeFrom(request->build_mode());
     if (!build_mode) {
       return Status(grpc::StatusCode::INTERNAL, "Invalid build mode");
     }