diff --git a/src/libstore/uds-remote-store.cc b/src/libstore/uds-remote-store.cc index 3c445eb1318..6f6dd70f6e2 100644 --- a/src/libstore/uds-remote-store.cc +++ b/src/libstore/uds-remote-store.cc @@ -1,6 +1,7 @@ #include "uds-remote-store.hh" #include "unix-domain-socket.hh" #include "worker-protocol.hh" +#include "store-registration.hh" #include #include @@ -20,13 +21,13 @@ namespace nix { UDSRemoteStoreConfig::UDSRemoteStoreConfig( std::string_view scheme, std::string_view authority, - const Params & params) + const StoreReference::Params & params) : StoreConfig(params) , LocalFSStoreConfig(params) , RemoteStoreConfig(params) , path{authority.empty() ? settings.nixDaemonSocketFile : authority} { - if (scheme != UDSRemoteStoreConfig::scheme) { + if (uriSchemes().count(std::string{scheme}) == 0) { throw UsageError("Scheme must be 'unix'"); } } @@ -40,23 +41,14 @@ std::string UDSRemoteStoreConfig::doc() } -// A bit gross that we now pass empty string but this is knowing that -// empty string will later default to the same nixDaemonSocketFile. Why -// don't we just wire it all through? I believe there are cases where it -// will live reload so we want to continue to account for that. -UDSRemoteStore::UDSRemoteStore(const Params & params) - : UDSRemoteStore(scheme, "", params) -{} - - -UDSRemoteStore::UDSRemoteStore(std::string_view scheme, std::string_view authority, const Params & params) - : StoreConfig(params) - , LocalFSStoreConfig(params) - , RemoteStoreConfig(params) - , UDSRemoteStoreConfig(scheme, authority, params) - , Store(params) - , LocalFSStore(params) - , RemoteStore(params) +UDSRemoteStore::UDSRemoteStore(const Config & config) + : Store::Config{config} + , LocalFSStore::Config{config} + , RemoteStore::Config{config} + , UDSRemoteStore::Config{config} + , Store(static_cast(*this)) + , LocalFSStore(static_cast(*this)) + , RemoteStore(static_cast(*this)) { } @@ -69,7 +61,7 @@ std::string UDSRemoteStore::getUri() // // unix:// with no path also works. Change what we return? "daemon" - : std::string(scheme) + "://" + path; + : std::string(*uriSchemes().begin()) + "://" + path; } @@ -106,6 +98,6 @@ void UDSRemoteStore::addIndirectRoot(const Path & path) } -static RegisterStoreImplementation regUDSRemoteStore; +static RegisterStoreImplementation regUDSRemoteStore; } diff --git a/src/libstore/uds-remote-store.hh b/src/libstore/uds-remote-store.hh index 8d19ad5f5bc..69fbf6f60a1 100644 --- a/src/libstore/uds-remote-store.hh +++ b/src/libstore/uds-remote-store.hh @@ -8,13 +8,17 @@ namespace nix { struct UDSRemoteStoreConfig : - virtual LocalFSStoreConfig, - virtual RemoteStoreConfig + virtual LocalFSStore::Config, + virtual RemoteStore::Config { - // TODO(fzakaria): Delete this constructor once moved over to the factory pattern - // outlined in https://github.com/NixOS/nix/issues/10766 - using LocalFSStoreConfig::LocalFSStoreConfig; - using RemoteStoreConfig::RemoteStoreConfig; + struct Descriptions : + virtual LocalFSStore::Config::Descriptions, + virtual RemoteStore::Config::Descriptions + { + Descriptions(); + }; + + static const Descriptions descriptions; /** * @param authority is the socket path. @@ -22,7 +26,7 @@ struct UDSRemoteStoreConfig : UDSRemoteStoreConfig( std::string_view scheme, std::string_view authority, - const Params & params); + const StoreReference::Params & params); const std::string name() override { return "Local Daemon Store"; } @@ -36,12 +40,10 @@ struct UDSRemoteStoreConfig : */ Path path; -private: - static constexpr char const * scheme = "unix"; - -public: static std::set uriSchemes() - { return {scheme}; } + { return {"unix"}; } + + ref openStore() const override; }; struct UDSRemoteStore : @@ -49,7 +51,9 @@ struct UDSRemoteStore : virtual IndirectRootStore, virtual RemoteStore { - UDSRemoteStore(const UDSRemoteStoreConfig &); + using Config = UDSRemoteStoreConfig; + + UDSRemoteStore(const Config &); std::string getUri() override;