about summary refs log tree commit diff
path: root/src/libstore/machines.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-05-02T11·44+0200
committerEelco Dolstra <edolstra@gmail.com>2017-05-02T13·42+0200
commit1a68710d4dff609bbaf61db3e17a2573f0aadf17 (patch)
tree433ebeb119f209dd69870a9d9b80c0de99de2846 /src/libstore/machines.cc
parentebc9f36a8111ddecc8e265e8a6a70048218f244d (diff)
Add an option for specifying remote builders
This is useful for one-off situations where you want to specify a
builder on the command line instead of having to mess with
nix.machines. E.g.

  $ nix-build -A hello --argstr system x86_64-darwin \
    --option builders 'root@macstadium1 x86_64-darwin'

will perform the specified build on "macstadium1".

It also removes the need for a separate nix.machines file since you
can specify builders in nix.conf directly. (In fact nix.machines is
yet another hack that predates the general nix.conf configuration
file, IIRC.)

Note: this option is supported by the daemon for trusted users. The
fact that this allows trusted users to specify paths to SSH keys to
which they don't normally have access is maybe a bit too much trust...
Diffstat (limited to 'src/libstore/machines.cc')
-rw-r--r--src/libstore/machines.cc18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/libstore/machines.cc b/src/libstore/machines.cc
index 471ce8efb9..479ed1432f 100644
--- a/src/libstore/machines.cc
+++ b/src/libstore/machines.cc
@@ -44,7 +44,7 @@ bool Machine::mandatoryMet(const std::set<string> & features) const {
 
 void parseMachines(const std::string & s, Machines & machines)
 {
-    for (auto line : tokenizeString<std::vector<string>>(s, "\n")) {
+    for (auto line : tokenizeString<std::vector<string>>(s, "\n;")) {
         chomp(line);
         line.erase(std::find(line.begin(), line.end(), '#'), line.end());
         if (line.empty()) continue;
@@ -62,4 +62,20 @@ void parseMachines(const std::string & s, Machines & machines)
     }
 }
 
+Machines getMachines()
+{
+    Machines machines;
+
+    try {
+        parseMachines(readFile(getEnv("NIX_REMOTE_SYSTEMS", settings.nixConfDir + "/machines")), machines);
+    } catch (const SysError & e) {
+        if (e.errNo != ENOENT)
+            throw;
+    }
+
+    parseMachines(settings.builders, machines);
+
+    return machines;
+}
+
 }