From 64e23d0a38f316a07cef0960d0ed74a450214283 Mon Sep 17 00:00:00 2001 From: Shea Levy Date: Sat, 8 Feb 2014 00:05:46 -0500 Subject: Add download-via-ssh substituter This substituter connects to a remote host, runs nix-store --serve there, and then forwards substituter commands on to the remote host and sends their results to the calling program. The ssh-substituter-hosts option can be specified as a list of hosts to try. This is an initial implementation and, while it works, it has some limitations: * Only the first host is used * There is no caching of query results (all queries are sent to the remote machine) * There is no informative output (such as progress bars) * Some failure modes may cause unhelpful error messages * There is no concept of trusted-ssh-substituter-hosts Signed-off-by: Shea Levy --- src/libstore/globals.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/libstore/globals.cc') diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 68add1982f43..c1ffc26fa30a 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -79,6 +79,7 @@ void Settings::processEnvironment() #endif substituters.push_back(nixLibexecDir + "/nix/substituters/download-using-manifests.pl"); substituters.push_back(nixLibexecDir + "/nix/substituters/download-from-binary-cache.pl"); + substituters.push_back(nixLibexecDir + "/nix/substituters/download-via-ssh"); } else substituters = tokenizeString(subs, ":"); } @@ -151,6 +152,7 @@ void Settings::update() get(gcKeepDerivations, "gc-keep-derivations"); get(autoOptimiseStore, "auto-optimise-store"); get(envKeepDerivations, "env-keep-derivations"); + get(sshSubstituterHosts, "ssh-substituter-hosts"); } @@ -182,6 +184,13 @@ void Settings::get(StringSet & res, const string & name) res.insert(ss.begin(), ss.end()); } +void Settings::get(Strings & res, const string & name) +{ + SettingsMap::iterator i = settings.find(name); + if (i == settings.end()) return; + res = tokenizeString(i->second); +} + template void Settings::get(N & res, const string & name) { @@ -206,6 +215,17 @@ string Settings::pack() } +void Settings::unpack(string pack) { + Strings lines = tokenizeString(pack, "\n"); + foreach (Strings::iterator, i, lines) { + string::size_type eq = i->find('='); + if (eq == string::npos) + throw Error("illegal option name/value"); + set(i->substr(0, eq), i->substr(eq + 1)); + } +} + + Settings::SettingsMap Settings::getOverrides() { return overrides; -- cgit 1.4.1