about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/derivations.cc
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-08-08T20·44-0400
committerglittershark <grfn@gws.fyi>2020-08-09T02·22+0000
commite440f60b6c74c6e2f406b4f187e6c20ee6d315dd (patch)
treede04c21c18bfa2f80f75144f3403a804a10ff477 /third_party/nix/src/libstore/derivations.cc
parent747dc6515410913aa8eec33d7e84f80e84b8773b (diff)
feat(tvix): Implement all remaining RPC calls r/1622
Implement all remaining RPC calls on the RpcSstore client, remove a few
stub methods we had added that weren't actually present in the old
RemoteStore implementation, and add one more RPC call for getBuildLog
that is present in the store API, but that we hadn't added as a
stub *or* to the proto.

Fixes: #29
Change-Id: Id827f51a393ece4bc7bbecaf38aee9eb4b329770
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1692
Reviewed-by: kanepyork <rikingcoding@gmail.com>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src/libstore/derivations.cc')
-rw-r--r--third_party/nix/src/libstore/derivations.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index b7dcded3de5e..0b7f5d092c43 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -5,6 +5,7 @@
 #include <absl/strings/string_view.h>
 #include <glog/logging.h>
 
+#include "libproto/worker.pb.h"
 #include "libstore/fs-accessor.hh"
 #include "libstore/globals.hh"
 #include "libstore/store-api.hh"
@@ -33,6 +34,14 @@ void DerivationOutput::parseHashInfo(bool& recursive, Hash& hash) const {
   hash = Hash::unwrap_throw(hash_);
 }
 
+nix::proto::Derivation_DerivationOutput DerivationOutput::to_proto() const {
+  nix::proto::Derivation_DerivationOutput result;
+  result.mutable_path()->set_path(path);
+  result.set_hash_algo(hashAlgo);
+  result.set_hash(hash);
+  return result;
+}
+
 BasicDerivation BasicDerivation::from_proto(
     const nix::proto::Derivation* proto_derivation, const nix::Store& store) {
   BasicDerivation result;
@@ -57,6 +66,27 @@ BasicDerivation BasicDerivation::from_proto(
   return result;
 }
 
+nix::proto::Derivation BasicDerivation::to_proto() const {
+  nix::proto::Derivation result;
+  for (const auto& [key, output] : outputs) {
+    result.mutable_outputs()->insert({key, output.to_proto()});
+  }
+  for (const auto& input_src : inputSrcs) {
+    result.mutable_input_sources()->add_paths(input_src);
+  }
+  result.set_platform(platform);
+  result.mutable_builder()->set_path(builder);
+  for (const auto& arg : args) {
+    result.add_args(arg);
+  }
+
+  for (const auto& [key, value] : env) {
+    result.mutable_env()->insert({key, value});
+  }
+
+  return result;
+}
+
 Path BasicDerivation::findOutput(const std::string& id) const {
   auto i = outputs.find(id);
   if (i == outputs.end()) {