aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/ssh-store.cc
diff options
context:
space:
mode:
authorregnat <rg@regnat.ovh>2020-09-08 14:50:23 +0200
committerregnat <rg@regnat.ovh>2020-09-16 13:53:08 +0200
commit7d5bdf8b5679cc7b2b9b4d9caf5af9ca52211336 (patch)
tree42c5061563eaa66a36a30380ccbac721e8c7423e /src/libstore/ssh-store.cc
parent609a6d6d9f1a8689c2336301a2e4db01ad20037c (diff)
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.
Diffstat (limited to 'src/libstore/ssh-store.cc')
-rw-r--r--src/libstore/ssh-store.cc14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc
index 6cb97c1f1..02208ee82 100644
--- a/src/libstore/ssh-store.cc
+++ b/src/libstore/ssh-store.cc
@@ -8,8 +8,6 @@
namespace nix {
-static std::string uriScheme = "ssh-ng://";
-
class SSHStore : public RemoteStore
{
public:
@@ -32,9 +30,11 @@ public:
{
}
+ static std::vector<std::string> uriPrefixes() { return {"ssh-ng"}; }
+
std::string getUri() override
{
- return uriScheme + host;
+ return uriPrefixes()[0] + "://" + host;
}
bool sameMachine() override
@@ -76,12 +76,6 @@ ref<RemoteStore::Connection> SSHStore::openConnection()
return conn;
}
-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<SSHStore>(std::string(uri, uriScheme.size()), params);
-});
+[[maybe_unused]] static RegisterStoreImplementation<SSHStore> regStore();
}