aboutsummaryrefslogtreecommitdiff
path: root/src/libstore/ssh-store.cc
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-16 22:35:24 +0000
committerJohn Ericson <John.Ericson@Obsidian.Systems>2020-09-16 22:35:24 +0000
commitf60b380a7f32406659efee282cde4c1330fc1c65 (patch)
tree8bd0680b8fafa02c93b29d0934133b0ff5b29e7a /src/libstore/ssh-store.cc
parentc08c9f08c75bf379439348cccb5b8871a27bf498 (diff)
parent5080d4e7b2525d1656282c65a217a22ff8381df3 (diff)
Merge remote-tracking branch 'upstream/master' into remove-storetype-delegate-regStore
Diffstat (limited to 'src/libstore/ssh-store.cc')
-rw-r--r--src/libstore/ssh-store.cc36
1 files changed, 19 insertions, 17 deletions
diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc
index 046b5710a..6d6eca98d 100644
--- a/src/libstore/ssh-store.cc
+++ b/src/libstore/ssh-store.cc
@@ -8,19 +8,25 @@
namespace nix {
-static std::string uriScheme = "ssh-ng://";
+struct SSHStoreConfig : virtual RemoteStoreConfig
+{
+ using RemoteStoreConfig::RemoteStoreConfig;
+
+ const Setting<Path> sshKey{(StoreConfig*) this, "", "ssh-key", "path to an SSH private key"};
+ const Setting<bool> compress{(StoreConfig*) this, false, "compress", "whether to compress the connection"};
+ const Setting<Path> remoteProgram{(StoreConfig*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"};
+ const Setting<std::string> remoteStore{(StoreConfig*) this, "", "remote-store", "URI of the store on the remote system"};
+
+ const std::string name() override { return "SSH Store"; }
+};
-class SSHStore : public RemoteStore
+class SSHStore : public virtual RemoteStore, public virtual SSHStoreConfig
{
public:
- const Setting<Path> sshKey{(Store*) this, "", "ssh-key", "path to an SSH private key"};
- const Setting<bool> compress{(Store*) this, false, "compress", "whether to compress the connection"};
- const Setting<Path> remoteProgram{(Store*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"};
- const Setting<std::string> remoteStore{(Store*) this, "", "remote-store", "URI of the store on the remote system"};
-
- SSHStore(const std::string & host, const Params & params)
- : Store(params)
+ SSHStore(const std::string & scheme, const std::string & host, const Params & params)
+ : StoreConfig(params)
+ , Store(params)
, RemoteStore(params)
, host(host)
, master(
@@ -32,9 +38,11 @@ public:
{
}
+ static std::set<std::string> uriSchemes() { return {"ssh-ng"}; }
+
std::string getUri() override
{
- return uriScheme + host;
+ return *uriSchemes().begin() + "://" + host;
}
bool sameMachine() override
@@ -75,12 +83,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);
-});
+static RegisterStoreImplementation<SSHStore, SSHStoreConfig> regStore;
}