1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-27 12:41:00 +01: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

@ -2,17 +2,15 @@
namespace nix {
static std::string uriScheme = "dummy://";
struct DummyStore : public Store
{
DummyStore(const Params & params)
DummyStore(const std::string uri, const Params & params)
: Store(params)
{ }
string getUri() override
{
return uriScheme;
return uriPrefixes()[0] + "://";
}
void queryPathInfoUncached(const StorePath & path,
@ -21,6 +19,10 @@ struct DummyStore : public Store
callback(nullptr);
}
static std::vector<std::string> uriPrefixes() {
return {"dummy"};
}
std::optional<StorePath> queryPathFromHashPart(const std::string & hashPart) override
{ unsupported("queryPathFromHashPart"); }
@ -48,12 +50,6 @@ struct DummyStore : public Store
{ unsupported("buildDerivation"); }
};
static RegisterStoreImplementation regStore([](
const std::string & uri, const Store::Params & params)
-> std::shared_ptr<Store>
{
if (uri != uriScheme) return nullptr;
return std::make_shared<DummyStore>(params);
});
[[maybe_unused]] static RegisterStoreImplementation<DummyStore> regStore();
}