about summary refs log tree commit diff
path: root/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-01T14·59-0400
committerglittershark <grfn@gws.fyi>2020-08-01T19·00+0000
commit3fdce7c6be52bd2b86bd8a75c06f27f94b753c4f (patch)
tree20e1c32bafe71c434dbd796f86e13c4d088ac061 /third_party/nix/src/nix-daemon/nix-daemon-proto.cc
parentee48e830e67ff53097f76ee2bde9ff60caf0dce7 (diff)
feat(3p/nix): Implement a few more RPC calls r/1529
Implement the RPC client calls for QueryPathFromHashPart,
QuerySubstitutablePaths, and QuerySubstitutablePathInfos, and the
handler for QuerySubstitutablePathInfos.

Refs: #29
Change-Id: Idf383b771f159f267d8f65367bc4af3d239e32b7
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1515
Tested-by: BuildkiteCI
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/nix-daemon/nix-daemon-proto.cc')
-rw-r--r--third_party/nix/src/nix-daemon/nix-daemon-proto.cc25
1 files changed, 25 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 27c694b29282..58f7754386e9 100644
--- a/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
+++ b/third_party/nix/src/nix-daemon/nix-daemon-proto.cc
@@ -17,6 +17,7 @@
 #include "libutil/archive.hh"
 #include "libutil/hash.hh"
 #include "libutil/serialise.hh"
+#include "libutil/types.hh"
 
 namespace nix::daemon {
 
@@ -170,6 +171,29 @@ class WorkerServiceImpl final : public WorkerService::Service {
     return Status::OK;
   }
 
+  Status QuerySubstitutablePathInfos(
+      grpc::ServerContext*, const StorePaths* request,
+      nix::proto::SubstitutablePathInfos* response) override {
+    SubstitutablePathInfos infos;
+    PathSet paths;
+    for (const auto& path : request->paths()) {
+      paths.insert(path);
+    }
+    store_->querySubstitutablePathInfos(paths, infos);
+    for (const auto& [path, path_info] : infos) {
+      auto proto_path_info = response->add_path_infos();
+      proto_path_info->mutable_path()->set_path(path);
+      proto_path_info->mutable_deriver()->set_path(path_info.deriver);
+      for (const auto& ref : path_info.references) {
+        proto_path_info->add_references(ref);
+      }
+      proto_path_info->set_download_size(path_info.downloadSize);
+      proto_path_info->set_nar_size(path_info.narSize);
+    }
+
+    return Status::OK;
+  }
+
   Status QueryValidDerivers(grpc::ServerContext* context,
                             const StorePath* request,
                             StorePaths* response) override {
@@ -216,6 +240,7 @@ class WorkerServiceImpl final : public WorkerService::Service {
                        PathInfo* response) override {
     auto path = request->path();
     store_->assertStorePath(path);
+    response->mutable_path()->set_path(path);
     try {
       auto info = store_->queryPathInfo(path);
       response->mutable_deriver()->set_path(info->deriver);