1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-07-02 21:51:50 +02:00

Make the store plugins more introspectable

Directly register the store classes rather than a function to build an
instance of them.
This gives the possibility to introspect static members of the class or
choose different ways of instantiating them.
This commit is contained in:
regnat 2020-09-08 14:50:23 +02:00
parent 609a6d6d9f
commit 7d5bdf8b56
18 changed files with 141 additions and 117 deletions

View file

@ -9,8 +9,6 @@
namespace nix {
static std::string uriScheme = "ssh://";
struct LegacySSHStore : public Store
{
const Setting<int> maxConnections{this, 1, "max-connections", "maximum number of concurrent SSH connections"};
@ -37,6 +35,9 @@ struct LegacySSHStore : public Store
SSHMaster master;
static std::vector<std::string> uriPrefixes() { return {"ssh"}; }
LegacySSHStore(const string & host, const Params & params)
: Store(params)
, host(host)
@ -84,7 +85,7 @@ struct LegacySSHStore : public Store
string getUri() override
{
return uriScheme + host;
return uriPrefixes()[0] + "://" + host;
}
void queryPathInfoUncached(const StorePath & path,
@ -325,12 +326,6 @@ public:
}
};
static RegisterStoreImplementation regStore([](
const std::string & uri, const Store::Params & params)
-> std::shared_ptr<Store>
{
if (std::string(uri, 0, uriScheme.size()) != uriScheme) return 0;
return std::make_shared<LegacySSHStore>(std::string(uri, uriScheme.size()), params);
});
[[maybe_unused]] static RegisterStoreImplementation<LegacySSHStore> regStore();
}