diff options
Diffstat (limited to 'third_party/nix/src')
-rw-r--r-- | third_party/nix/src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | third_party/nix/src/libstore/CMakeLists.txt | 1 | ||||
-rw-r--r-- | third_party/nix/src/nix-daemon/nix-daemon.cc | 1 | ||||
-rw-r--r-- | third_party/nix/src/proto/CMakeLists.txt | 37 | ||||
-rw-r--r-- | third_party/nix/src/proto/worker.proto | 88 |
5 files changed, 128 insertions, 0 deletions
diff --git a/third_party/nix/src/CMakeLists.txt b/third_party/nix/src/CMakeLists.txt index 37ff3b54af94..3f30b1672562 100644 --- a/third_party/nix/src/CMakeLists.txt +++ b/third_party/nix/src/CMakeLists.txt @@ -5,6 +5,7 @@ # this location and this setup mimics that (with the exception of the # various Nix libraries). +add_subdirectory(proto) add_subdirectory(libutil) add_subdirectory(libstore) add_subdirectory(libmain) diff --git a/third_party/nix/src/libstore/CMakeLists.txt b/third_party/nix/src/libstore/CMakeLists.txt index 4bc7b8fd5db2..705be9574d2f 100644 --- a/third_party/nix/src/libstore/CMakeLists.txt +++ b/third_party/nix/src/libstore/CMakeLists.txt @@ -88,6 +88,7 @@ target_sources(nixstore ) target_link_libraries(nixstore + nixproto nixutil BZip2::BZip2 diff --git a/third_party/nix/src/nix-daemon/nix-daemon.cc b/third_party/nix/src/nix-daemon/nix-daemon.cc index b2161f8584db..c7967307c1ba 100644 --- a/third_party/nix/src/nix-daemon/nix-daemon.cc +++ b/third_party/nix/src/nix-daemon/nix-daemon.cc @@ -27,6 +27,7 @@ #include "libutil/serialise.hh" #include "libutil/util.hh" #include "nix/legacy.hh" +#include "libproto/worker.pb.h" using namespace nix; diff --git a/third_party/nix/src/proto/CMakeLists.txt b/third_party/nix/src/proto/CMakeLists.txt new file mode 100644 index 000000000000..726ca8742f86 --- /dev/null +++ b/third_party/nix/src/proto/CMakeLists.txt @@ -0,0 +1,37 @@ +# -*- mode: cmake; -*- +# +# The proto generation happens outside of CMake and the path to the +# generated files is passed in via the environment variable +# $NIX_PROTO_SRCS. +# +# This configuration defines a library target that compiles these +# sources and makes the headers available. + +add_library(nixproto SHARED) +set_property(TARGET nixproto PROPERTY CXX_STANDARD 17) + +set(HEADER_FILES + $ENV{NIX_PROTO_SRCS}/libproto/worker.grpc.pb.h + $ENV{NIX_PROTO_SRCS}/libproto/worker.pb.h +) + +target_sources(nixproto + PUBLIC + ${HEADER_FILES} + + PRIVATE + $ENV{NIX_PROTO_SRCS}/libproto/worker.grpc.pb.cc + $ENV{NIX_PROTO_SRCS}/libproto/worker.pb.cc +) + +target_link_libraries(nixproto + gRPC::grpc++_reflection + protobuf::libprotobuf +) + +target_include_directories(nixproto + INTERFACE $ENV{NIX_PROTO_SRCS} +) + +INSTALL(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/nix/libproto) +INSTALL(TARGETS nixproto DESTINATION ${CMAKE_INSTALL_LIBDIR}) 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; +} |