From 7f2c991f7cd0e08b2fa32be18ef146175ad235a3 Mon Sep 17 00:00:00 2001 From: Daiderd Jordan Date: Mon, 3 Feb 2020 23:18:34 +0100 Subject: [PATCH 1/2] ssh-store: add remote-store and remote-program query params Brings the functionality of ssh-ng:// in sync with the legacy ssh:// implementation. Specifying the remote store uri enables various useful things. eg. $ nix copy --to ssh-ng://cache?remote-store=file://mnt/cache --all (cherry picked from commit 8745c63d3c674871393aa3f56c8457b056af8c87) --- src/libstore/ssh-store.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc index 7800968f1..40c3ccdcc 100644 --- a/src/libstore/ssh-store.cc +++ b/src/libstore/ssh-store.cc @@ -17,6 +17,8 @@ public: const Setting sshKey{(Store*) this, "", "ssh-key", "path to an SSH private key"}; const Setting sshPublicHostKey{(Store*) this, "", "base64-ssh-public-host-key", "The public half of the host's SSH key"}; const Setting compress{(Store*) this, false, "compress", "whether to compress the connection"}; + const Setting remoteProgram{this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"}; + const Setting remoteStore{this, "", "remote-store", "URI of the store on the remote system"}; SSHStore(const std::string & host, const Params & params) : Store(params) @@ -84,7 +86,9 @@ ref SSHStore::getFSAccessor() ref SSHStore::openConnection() { auto conn = make_ref(); - conn->sshConn = master.startCommand("nix-daemon --stdio"); + conn->sshConn = master.startCommand( + fmt("%s --stdio", remoteProgram) + + (remoteStore.get() == "" ? "" : " --store " + shellEscape(remoteStore.get()))); conn->to = FdSink(conn->sshConn->in.get()); conn->from = FdSource(conn->sshConn->out.get()); initConnection(*conn); From 2ee48c29a90291b9b1b8c6a61d11da421e4a73e7 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 7 Feb 2020 13:01:48 +0100 Subject: [PATCH 2/2] Fix segfault in gcc on i686-linux src/libstore/ssh-store.cc: In constructor 'nix::SSHStore::SSHStore(const string&, const Params&)': src/libstore/ssh-store.cc:31:21: internal compiler error: Segmentation fault compress) ^ Please submit a full bug report, with preprocessed source if appropriate. https://hydra.nixos.org/build/111545609 (cherry picked from commit d82b78bf51b2d8f626264fa992a907dd1088389a) --- src/libstore/ssh-store.cc | 4 ++-- src/libstore/store-api.hh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libstore/ssh-store.cc b/src/libstore/ssh-store.cc index 40c3ccdcc..c2bff2b72 100644 --- a/src/libstore/ssh-store.cc +++ b/src/libstore/ssh-store.cc @@ -17,8 +17,8 @@ public: const Setting sshKey{(Store*) this, "", "ssh-key", "path to an SSH private key"}; const Setting sshPublicHostKey{(Store*) this, "", "base64-ssh-public-host-key", "The public half of the host's SSH key"}; const Setting compress{(Store*) this, false, "compress", "whether to compress the connection"}; - const Setting remoteProgram{this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"}; - const Setting remoteStore{this, "", "remote-store", "URI of the store on the remote system"}; + const Setting remoteProgram{(Store*) this, "nix-daemon", "remote-program", "path to the nix-daemon executable on the remote system"}; + const Setting remoteStore{(Store*) this, "", "remote-store", "URI of the store on the remote system"}; SSHStore(const std::string & host, const Params & params) : Store(params) diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index ace769ea6..214803f52 100644 --- a/src/libstore/store-api.hh +++ b/src/libstore/store-api.hh @@ -680,7 +680,7 @@ class LocalFSStore : public virtual Store public: // FIXME: the (Store*) cast works around a bug in gcc that causes - // it to emit the call to the Option constructor. Clang works fine + // it to omit the call to the Setting constructor. Clang works fine // either way. const PathSetting rootDir{(Store*) this, true, "", "root", "directory prefixed to all other paths"};