feat(3p/nix/proto): Add additional worker-protocol operations

On the chopping block this time:

* requests/responses that return one or more store paths, and contain
  nothing else, have been changed to use the same types (StorePath and
  StorePaths, respectively)
* QuerySubstitutablePathInfos has been added. It should be noted that
  legacy Nix has two versions of this call, one that only queries a
  single info (deprecated) and one that queries multiple. We have only
  implemented the latter.
* QueryDerivationOutputs has been added.

Change-Id: Iccc9041e7064e141cf593467ecdcc327581c4056
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1186
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
This commit is contained in:
Vincent Ambo 2020-07-16 02:10:20 +01:00 committed by tazjin
parent 1bd08e73cd
commit 622250bff9

View file

@ -8,37 +8,37 @@ package nix.proto;
// with the Nix store. // with the Nix store.
service Worker { service Worker {
// Validates whether the supplied path is a valid store path. // Validates whether the supplied path is a valid store path.
rpc IsValidPath (IsValidPathRequest) returns (IsValidPathResponse); rpc IsValidPath(StorePath) returns (IsValidPathResponse);
// Checks whether any substitutes exist for the given path. // Checks whether any substitutes exist for the given path.
rpc HasSubstitutes (HasSubstitutesRequest) returns (HasSubstitutesResponse); rpc HasSubstitutes(StorePath) returns (HasSubstitutesResponse);
// Query referrers for a given path. // Query referrers for a given path.
rpc QueryReferrers (QueryReferrersRequest) returns (QueryReferrersResponse); rpc QueryReferrers(StorePath) returns (StorePaths);
// Add a NAR (I think?) to the store. The first stream request // Add a NAR (I think?) to the store. The first stream request
// should be a message indicating metadata, the rest should be file // should be a message indicating metadata, the rest should be file
// chunks. // chunks.
rpc AddToStore (stream AddToStoreRequest) returns (AddToStoreResponse); rpc AddToStore(stream AddToStoreRequest) returns (StorePath);
// Adds the supplied string to the store, as a text file. // Adds the supplied string to the store, as a text file.
rpc AddTextToStore (AddTextToStoreRequest) returns (AddTextToStoreResponse); rpc AddTextToStore(AddTextToStoreRequest) returns (StorePath);
// Build the specified derivations in one of the specified build // Build the specified derivations in one of the specified build
// modes, defaulting to a normal build. // modes, defaulting to a normal build.
rpc BuildPaths (BuildPathsRequest) returns (google.protobuf.Empty); rpc BuildPaths(BuildPathsRequest) returns (google.protobuf.Empty);
// TODO: What does this do? // TODO: What does this do?
rpc EnsurePath (EnsurePathRequest) returns (google.protobuf.Empty); rpc EnsurePath(StorePath) returns (google.protobuf.Empty);
// TODO: What does this do? // TODO: What does this do?
rpc AddTempRoot (AddTempRootRequest) returns (google.protobuf.Empty); rpc AddTempRoot(StorePath) returns (google.protobuf.Empty);
// TODO: What does this do? // TODO: What does this do?
rpc AddIndirectRoot (AddIndirectRootRequest) returns (google.protobuf.Empty); rpc AddIndirectRoot(StorePath) returns (google.protobuf.Empty);
// TODO: What does this do? // TODO: What does this do?
rpc SyncWithGC (google.protobuf.Empty) returns (google.protobuf.Empty); rpc SyncWithGC(google.protobuf.Empty) returns (google.protobuf.Empty);
// TODO: What does this do? // TODO: What does this do?
rpc FindRoots(google.protobuf.Empty) returns (FindRootsResponse); rpc FindRoots(google.protobuf.Empty) returns (FindRootsResponse);
@ -49,11 +49,17 @@ service Worker {
// Ask the store to perform a garbage collection, based on the // Ask the store to perform a garbage collection, based on the
// specified parameters. See `GCAction` for the possible actions. // specified parameters. See `GCAction` for the possible actions.
rpc CollectGarbage(CollectGarbageRequest) returns (CollectGarbageResponse); rpc CollectGarbage(CollectGarbageRequest) returns (CollectGarbageResponse);
// TODO: What does this do?
rpc QuerySubstitutablePathInfos(StorePaths) returns (SubstitutablePathInfos);
// TODO: What does this do?
rpc QueryDerivationOutputs(StorePath) returns (StorePaths);
} }
enum HashType { enum HashType {
UNKNOWN = 0; UNKNOWN = 0;
MD5 = 1; // TODO(tazjin): still needed? MD5 = 1; // TODO(tazjin): still needed?
SHA1 = 2; SHA1 = 2;
SHA256 = 3; SHA256 = 3;
SHA512 = 4; SHA512 = 4;
@ -81,34 +87,30 @@ enum GCAction {
DeleteSpecific = 3; DeleteSpecific = 3;
} }
message IsValidPathRequest { // Generic type for any RPC call that just reads or returns a single
// store path.
message StorePath {
string path = 1; string path = 1;
} }
// Generic type for any RPC call that just reads or returns a list of
// store paths.
message StorePaths {
repeated string paths = 1;
}
message IsValidPathResponse { message IsValidPathResponse {
bool is_valid = 1; bool is_valid = 1;
} }
message HasSubstitutesRequest {
string path = 1;
}
message HasSubstitutesResponse { message HasSubstitutesResponse {
bool has_substitutes = 1; bool has_substitutes = 1;
} }
message QueryReferrersRequest {
string path = 1;
}
message QueryReferrersResponse {
repeated string paths = 1;
}
message AddToStoreRequest { message AddToStoreRequest {
message Metadata { message Metadata {
bool fixed = 1; bool fixed = 1;
bool recursive = 2; // TODO(tazjin): what is this? "obsolete" comment? bool recursive = 2; // TODO(tazjin): what is this? "obsolete" comment?
HashType hash_type = 3; HashType hash_type = 3;
string base_name = 4; string base_name = 4;
} }
@ -124,37 +126,17 @@ message AddToStoreRequest {
} }
} }
message AddToStoreResponse {
string path = 1;
}
message AddTextToStoreRequest { message AddTextToStoreRequest {
string name = 1; string name = 1;
string content = 2; string content = 2;
repeated string references = 3; repeated string references = 3;
} }
message AddTextToStoreResponse {
string path = 1;
}
message BuildPathsRequest { message BuildPathsRequest {
repeated string drvs = 1; repeated string drvs = 1;
BuildMode mode = 2; BuildMode mode = 2;
} }
message EnsurePathRequest {
string path = 1;
}
message AddTempRootRequest {
string path = 1;
}
message AddIndirectRootRequest {
string path = 1;
}
message FindRootsResponse { message FindRootsResponse {
map<string, string> roots = 1; map<string, string> roots = 1;
} }
@ -164,10 +146,11 @@ message SetOptionsRequest {
bool keep_going = 2; bool keep_going = 2;
bool try_fallback = 3; bool try_fallback = 3;
uint32 max_build_jobs = 4; uint32 max_build_jobs = 4;
uint32 verbose_build = 5; // TODO(tazjin): Maybe this should be bool, unclear. uint32 verbose_build =
uint32 build_cores = 6; // TODO(tazjin): Difference from max_build_jobs? 5; // TODO(tazjin): Maybe this should be bool, unclear.
uint32 build_cores = 6; // TODO(tazjin): Difference from max_build_jobs?
bool use_substitutes = 7; bool use_substitutes = 7;
map<string, string> overrides = 8; // TODO(tazjin): better name? map<string, string> overrides = 8; // TODO(tazjin): better name?
} }
message CollectGarbageRequest { message CollectGarbageRequest {
@ -196,3 +179,15 @@ message CollectGarbageResponse {
// of bytes that would be or was freed. // of bytes that would be or was freed.
uint64 bytes_freed = 2; uint64 bytes_freed = 2;
} }
message SubstitutablePathInfos {
message PathInfo {
string path = 1;
string deriver = 2;
uint64 download_size = 3;
uint64 nar_size = 4;
repeated string references = 5;
}
repeated PathInfo path_infos = 1;
}