about summary refs log tree commit diff
path: root/third_party/nix/src
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2020-07-05T18·59+0100
committertazjin <mail@tazj.in>2020-07-05T19·17+0000
commita6da980a0b4b95e1ac06d20aca7fbe59fff3c36c (patch)
treec5c3cb483fd0519da0eefb422f57735b7ddae4e1 /third_party/nix/src
parentf8a933b21a1fa3d302e10157f8b2b1164133269c (diff)
feat(3p/nix): Add gRPC definitions for worker protocol r/1215
Adds initial gRPC definitions for the Nix worker protocol, which is
currently defined messily across the following files:

    src/libstore/worker-protocol.hh
    src/libstore/remote-store.cc
    src/nix-daemon/nix-daemon.cc

The protocol definition is basically a big enum with the signatures of
the calls being implicit in the various client/server implementation
functions.

The definitions in this file are slowly reversed from these implicit
signatures, and are likely to contain an error or two which will be
weeded out when this is taken into use.

Only a handful of the calls are included in this commit, it is
intended to get us up and running first.

Change-Id: Ibc9b2ab4b91a064c8935f09f7ac72bb8150fb476
Reviewed-on: https://cl.tvl.fyi/c/depot/+/926
Reviewed-by: isomer <isomer@tvl.fyi>
Tested-by: BuildkiteCI
Diffstat (limited to 'third_party/nix/src')
-rw-r--r--third_party/nix/src/proto/worker.proto88
1 files changed, 88 insertions, 0 deletions
diff --git a/third_party/nix/src/proto/worker.proto b/third_party/nix/src/proto/worker.proto
new file mode 100644
index 000000000000..8db1a9e808d2
--- /dev/null
+++ b/third_party/nix/src/proto/worker.proto
@@ -0,0 +1,88 @@
+syntax = "proto3";
+
+package nix.proto;
+
+// Service representing a worker used for building and interfacing
+// with the Nix store.
+service Worker {
+  // Validates whether the supplied path is a valid store path.
+  rpc IsValidPath (IsValidPathRequest) returns (IsValidPathResponse);
+
+  // Checks whether any substitutes exist for the given path.
+  rpc HasSubstitutes (HasSubstitutesRequest) returns (HasSubstitutesResponse);
+
+  // Query referrers for a given path.
+  rpc QueryReferrers (QueryReferrersRequest) returns (QueryReferrersResponse);
+
+  // Add a NAR (I think?) to the store. The first stream request
+  // should be a message indicating metadata, the rest should be file
+  // chunks.
+  rpc AddToStore (stream AddToStoreRequest) returns (AddToStoreResponse);
+
+  // Adds the supplied string to the store, as a text file.
+  rpc AddTextToStore (AddTextToStoreRequest) returns (AddTextToStoreResponse);
+}
+
+enum HashType {
+  MD5 = 0; // TODO(tazjin): still needed?
+  SHA1 = 1;
+  SHA256 = 2;
+  SHA512 = 3;
+}
+
+message IsValidPathRequest {
+  string path = 1;
+}
+
+message IsValidPathResponse {
+  bool is_valid = 1;
+}
+
+message HasSubstitutesRequest {
+  string path = 1;
+}
+
+message HasSubstitutesResponse {
+  bool has_substitutes = 1;
+}
+
+message QueryReferrersRequest {
+  string path = 1;
+}
+
+message QueryReferrersResponse {
+  repeated string paths = 1;
+}
+
+message AddToStoreRequest {
+  message Metadata {
+    bool fixed = 1;
+    bool recursive = 2; // TODO(tazjin): what is this? "obsolete" comment?
+    HashType hash_type = 3;
+    string base_name = 4;
+  }
+
+  message Chunk {
+    bytes content = 1;
+    bool final = 2;
+  }
+
+  oneof add_oneof {
+    Metadata meta = 1;
+    Chunk chunk = 2;
+  }
+}
+
+message AddToStoreResponse {
+  string path = 1;
+}
+
+message AddTextToStoreRequest {
+  string name = 1;
+  string content = 2;
+  repeated string references = 3;
+}
+
+message AddTextToStoreResponse {
+  string path = 1;
+}