From 059468ba154fbf6652c89ffe8052c9c8571f6c3e Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sat, 8 Aug 2020 16:47:50 -0400 Subject: [PATCH] refactor(tvix): Remove UDSRemoteStore Now that we've fully implemented the RPC-based store client, we can get rid of the UDSRemoteStore, whose only use was connecting to the locally running nix daemon. The RemoteStore still needs to be around to connect to remote upstream nix stores over SSH. Change-Id: I0699819803cbfe966b9a46786f2c927d8e4bf1a2 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1693 Tested-by: BuildkiteCI Reviewed-by: kanepyork --- third_party/nix/src/libstore/remote-store.cc | 62 -------------------- third_party/nix/src/libstore/remote-store.hh | 14 ----- 2 files changed, 76 deletions(-) diff --git a/third_party/nix/src/libstore/remote-store.cc b/third_party/nix/src/libstore/remote-store.cc index 784a95d2e..41881f8ef 100644 --- a/third_party/nix/src/libstore/remote-store.cc +++ b/third_party/nix/src/libstore/remote-store.cc @@ -69,56 +69,6 @@ ref RemoteStore::openConnectionWrapper() { } } -UDSRemoteStore::UDSRemoteStore(const Params& params) - : Store(params), LocalFSStore(params), RemoteStore(params) {} - -UDSRemoteStore::UDSRemoteStore(std::string socket_path, const Params& params) - : Store(params), - LocalFSStore(params), - RemoteStore(params), - path(socket_path) {} - -std::string UDSRemoteStore::getUri() { - if (path) { - return std::string("unix://") + *path; - } - return "daemon"; -} - -ref UDSRemoteStore::openConnection() { - auto conn = make_ref(); - - /* Connect to a daemon that does the privileged work for us. */ - conn->fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0); - if (!conn->fd) { - throw SysError("cannot create Unix domain socket"); - } - closeOnExec(conn->fd.get()); - - std::string socketPath = path ? *path : settings.nixDaemonSocketFile; - - struct sockaddr_un addr; - addr.sun_family = AF_UNIX; - strncpy(addr.sun_path, socketPath.c_str(), sizeof(addr.sun_path)); - if (addr.sun_path[sizeof(addr.sun_path) - 1] != '\0') { - throw Error(format("socket path '%1%' is too long") % socketPath); - } - - if (::connect(conn->fd.get(), reinterpret_cast(&addr), - sizeof(addr)) == -1) { - throw SysError(format("cannot connect to daemon at '%1%'") % socketPath); - } - - conn->from.fd = conn->fd.get(); - conn->to.fd = conn->fd.get(); - - conn->startTime = std::chrono::steady_clock::now(); - - initConnection(*conn); - - return conn; -} - void RemoteStore::initConnection(Connection& conn) { /* Send the magic greeting, check for the reply. */ try { @@ -727,16 +677,4 @@ std::exception_ptr RemoteStore::Connection::processStderr(Sink* sink, return nullptr; } -static std::string uriScheme = "unix://"; - -static RegisterStoreImplementation regStore( - [](const std::string& uri, - const Store::Params& params) -> std::shared_ptr { - if (std::string(uri, 0, uriScheme.size()) != uriScheme) { - return nullptr; - } - return std::make_shared( - std::string(uri, uriScheme.size()), params); - }); - } // namespace nix diff --git a/third_party/nix/src/libstore/remote-store.hh b/third_party/nix/src/libstore/remote-store.hh index 927d08335..a6829226c 100644 --- a/third_party/nix/src/libstore/remote-store.hh +++ b/third_party/nix/src/libstore/remote-store.hh @@ -136,18 +136,4 @@ class RemoteStore : public virtual Store { std::atomic_bool failed{false}; }; -class UDSRemoteStore : public LocalFSStore, public RemoteStore { - public: - UDSRemoteStore(const Params& params); - UDSRemoteStore(std::string path, const Params& params); - - std::string getUri() override; - - bool sameMachine() override { return true; } - - private: - ref openConnection() override; - std::optional path; -}; - } // namespace nix