From 7f6837a0f6e7702a9e8c6da622873b955aa414cd Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 2 May 2017 14:36:59 +0200 Subject: Replace $NIX_REMOTE_SYSTEMS with an option "builder-files" Also, to unify with hydra-queue-runner, allow it to be a list of files. --- src/libstore/machines.cc | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) (limited to 'src/libstore/machines.cc') diff --git a/src/libstore/machines.cc b/src/libstore/machines.cc index 479ed1432fb5..c1d9047537d3 100644 --- a/src/libstore/machines.cc +++ b/src/libstore/machines.cc @@ -12,7 +12,8 @@ Machine::Machine(decltype(storeUri) storeUri, decltype(maxJobs) maxJobs, decltype(speedFactor) speedFactor, decltype(supportedFeatures) supportedFeatures, - decltype(mandatoryFeatures) mandatoryFeatures) : + decltype(mandatoryFeatures) mandatoryFeatures, + decltype(sshPublicHostKey) sshPublicHostKey) : storeUri( // Backwards compatibility: if the URI is a hostname, // prepend ssh://. @@ -24,7 +25,8 @@ Machine::Machine(decltype(storeUri) storeUri, maxJobs(maxJobs), speedFactor(std::max(1U, speedFactor)), supportedFeatures(supportedFeatures), - mandatoryFeatures(mandatoryFeatures) + mandatoryFeatures(mandatoryFeatures), + sshPublicHostKey(sshPublicHostKey) {} bool Machine::allSupported(const std::set & features) const { @@ -52,13 +54,19 @@ void parseMachines(const std::string & s, Machines & machines) auto sz = tokens.size(); if (sz < 1) throw FormatError("bad machine specification ā€˜%sā€™", line); + + auto isSet = [&](int n) { + return tokens.size() > n && tokens[n] != "" && tokens[n] != "-"; + }; + machines.emplace_back(tokens[0], - sz >= 2 ? tokenizeString>(tokens[1], ",") : std::vector{settings.thisSystem}, - sz >= 3 ? tokens[2] : "", - sz >= 4 ? std::stoull(tokens[3]) : 1LL, - sz >= 5 ? std::stoull(tokens[4]) : 1LL, - sz >= 6 ? tokenizeString>(tokens[5], ",") : std::set{}, - sz >= 7 ? tokenizeString>(tokens[6], ",") : std::set{}); + isSet(1) ? tokenizeString>(tokens[1], ",") : std::vector{settings.thisSystem}, + isSet(2) ? tokens[2] : "", + isSet(3) ? std::stoull(tokens[3]) : 1LL, + isSet(4) ? std::stoull(tokens[4]) : 1LL, + isSet(5) ? tokenizeString>(tokens[5], ",") : std::set{}, + isSet(6) ? tokenizeString>(tokens[6], ",") : std::set{}, + isSet(7) ? tokens[7] : ""); } } @@ -66,11 +74,13 @@ Machines getMachines() { Machines machines; - try { - parseMachines(readFile(getEnv("NIX_REMOTE_SYSTEMS", settings.nixConfDir + "/machines")), machines); - } catch (const SysError & e) { - if (e.errNo != ENOENT) - throw; + for (auto & file : settings.builderFiles.get()) { + try { + parseMachines(readFile(file), machines); + } catch (const SysError & e) { + if (e.errNo != ENOENT) + throw; + } } parseMachines(settings.builders, machines); -- cgit 1.4.1