diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-07-25T17·49-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-07-25T20·18+0000 |
commit | b10970a66f39e91f36975a2e83166c0192d9476e (patch) | |
tree | 4b3d9e3c08791fab0e19f6f5a2c6a0003d345bc9 /third_party/nix/src/libstore/store-api.cc | |
parent | dcaba9de64354fa699ee6b292efbedfb984582db (diff) |
feat(3p/nix): Start implementing RPC store client r/1473
Add a stub class for wrapping a gRPC client to the new, proto-backed nix store protocol, along with several methods implemented but several left throwing a not implemented exception. Paired-With: Vincent Ambo <mail@tazj.in> Paired-With: Perry Lorier <isomer@tvl.fyi> Change-Id: Id943d4f6d75084b8498786d580e6c9f7c92c104d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1436 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'third_party/nix/src/libstore/store-api.cc')
-rw-r--r-- | third_party/nix/src/libstore/store-api.cc | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc index 47f85e6e2610..12c60dffca35 100644 --- a/third_party/nix/src/libstore/store-api.cc +++ b/third_party/nix/src/libstore/store-api.cc @@ -7,11 +7,13 @@ #include <absl/strings/numbers.h> #include <absl/strings/str_split.h> #include <glog/logging.h> +#include <grpcpp/create_channel.h> #include "libstore/crypto.hh" #include "libstore/derivations.hh" #include "libstore/globals.hh" #include "libstore/nar-info-disk-cache.hh" +#include "libstore/rpc-store.hh" #include "libutil/json.hh" #include "libutil/thread-pool.hh" #include "libutil/util.hh" @@ -978,23 +980,28 @@ StoreType getStoreType(const std::string& uri, const std::string& stateDir) { } } -static RegisterStoreImplementation regStore([](const std::string& uri, - const Store::Params& params) - -> std::shared_ptr<Store> { - switch (getStoreType(uri, get(params, "state", settings.nixStateDir))) { - case tDaemon: - return std::shared_ptr<Store>(std::make_shared<UDSRemoteStore>(params)); - case tLocal: { - Store::Params params2 = params; - if (absl::StartsWith(uri, "/")) { - params2["root"] = uri; +static RegisterStoreImplementation regStore( + [](const std::string& uri, + const Store::Params& params) -> std::shared_ptr<Store> { + switch (getStoreType(uri, get(params, "state", settings.nixStateDir))) { + case tDaemon: { + auto daemon_socket_uri = settings.nixDaemonSocketFile; + auto channel = grpc::CreateChannel( + daemon_socket_uri, grpc::InsecureChannelCredentials()); + return std::shared_ptr<Store>(std::make_shared<nix::store::RpcStore>( + params, proto::WorkerService::NewStub(channel))); + } + case tLocal: { + Store::Params params2 = params; + if (absl::StartsWith(uri, "/")) { + params2["root"] = uri; + } + return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2)); + } + default: + return nullptr; } - return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2)); - } - default: - return nullptr; - } -}); + }); std::list<ref<Store>> getDefaultSubstituters() { static auto stores([]() { |