LegacySSHStore: Add remote-store option

This is primarily useful for testing, e.g.

  $ nix copy --to 'ssh://localhost?remote-store=/tmp/nix' ...
This commit is contained in:
Eelco Dolstra 2018-08-03 18:07:46 +02:00
parent 25da1c64f9
commit e268bbc054
No known key found for this signature in database
GPG Key ID: 8170B4726D7198DE

View File

@ -17,6 +17,7 @@ struct LegacySSHStore : public Store
const Setting<Path> sshKey{this, "", "ssh-key", "path to an SSH private key"};
const Setting<bool> compress{this, false, "compress", "whether to compress the connection"};
const Setting<Path> remoteProgram{this, "nix-store", "remote-program", "path to the nix-store executable on the remote system"};
const Setting<std::string> remoteStore{this, "", "remote-store", "URI of the store on the remote system"};
// Hack for getting remote build log output.
const Setting<int> logFD{this, -1, "log-fd", "file descriptor to which SSH's stderr is connected"};
@ -56,7 +57,9 @@ struct LegacySSHStore : public Store
ref<Connection> openConnection()
{
auto conn = make_ref<Connection>();
conn->sshConn = master.startCommand(fmt("%s --serve --write", remoteProgram));
conn->sshConn = master.startCommand(
fmt("%s --serve --write", remoteProgram)
+ (remoteStore.get() == "" ? "" : " --store " + shellEscape(remoteStore.get())));
conn->to = FdSink(conn->sshConn->in.get());
conn->from = FdSource(conn->sshConn->out.get());