about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/rpc-store.cc
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/libstore/rpc-store.cc
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/libstore/rpc-store.cc')
-rw-r--r--third_party/nix/src/libstore/rpc-store.cc27
1 files changed, 24 insertions, 3 deletions
diff --git a/third_party/nix/src/libstore/rpc-store.cc b/third_party/nix/src/libstore/rpc-store.cc
index ba7d77fb08..4a55e09967 100644
--- a/third_party/nix/src/libstore/rpc-store.cc
+++ b/third_party/nix/src/libstore/rpc-store.cc
@@ -214,9 +214,23 @@ Path RpcStore::addToStore(const std::string& name, const Path& srcPath,
   throw absl::StrCat("Not implemented ", __func__);
 }
 
-Path RpcStore::addTextToStore(const std::string& name, const std::string& s,
+Path RpcStore::addTextToStore(const std::string& name,
+                              const std::string& content,
                               const PathSet& references, RepairFlag repair) {
-  throw absl::StrCat("Not implemented ", __func__);
+  if (repair != 0u) {
+    throw Error(
+        "repairing is not supported when building through the Nix daemon");
+  }
+  ClientContext ctx;
+  proto::AddTextToStoreRequest request;
+  request.set_name(name);
+  request.set_content(content);
+  for (const auto& ref : references) {
+    request.add_references(ref);
+  }
+  proto::StorePath result;
+  SuccessOrThrow(stub_->AddTextToStore(&ctx, request, &result));
+  return result.path();
 }
 
 void RpcStore::narFromPath(const Path& path, Sink& sink) {
@@ -224,7 +238,14 @@ void RpcStore::narFromPath(const Path& path, Sink& sink) {
 }
 
 void RpcStore::buildPaths(const PathSet& paths, BuildMode buildMode) {
-  throw absl::StrCat("Not implemented ", __func__);
+  ClientContext ctx;
+  proto::BuildPathsRequest request;
+  for (const auto& path : paths) {
+    request.add_drvs(path);
+  }
+  google::protobuf::Empty response;
+  request.set_mode(nix::BuildModeToProto(buildMode));
+  SuccessOrThrow(stub_->BuildPaths(&ctx, request, &response));
 }
 
 BuildResult RpcStore::buildDerivation(const Path& drvPath,