about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/build.cc12
-rw-r--r--src/libutil/util.cc11
-rw-r--r--src/libutil/util.hh5
3 files changed, 26 insertions, 2 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index f2781776c6ef..f9c9a0a1eae5 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1327,8 +1327,16 @@ HookReply DerivationGoal::tryBuildHook()
     if (!worker.hook)
         worker.hook = boost::shared_ptr<HookInstance>(new HookInstance);
 
-    writeLine(worker.hook->toHook.writeSide, (format("%1% %2% %3%") %
-        (worker.getNrLocalBuilds() < maxBuildJobs ? "1" : "0") % drv.platform % drvPath).str());
+    /* Tell the hook about system features (beyond the system type)
+       required from the build machine.  (The hook could parse the
+       drv file itself, but this is easier.) */
+    Strings features = tokenizeString(drv.env["requiredSystemFeatures"]);
+    foreach (Strings::iterator, i, features) checkStoreName(*i); /* !!! abuse */
+
+    /* Send the request to the hook. */
+    writeLine(worker.hook->toHook.writeSide, (format("%1% %2% %3% %4%")
+        % (worker.getNrLocalBuilds() < maxBuildJobs ? "1" : "0")
+        % drv.platform % drvPath % concatStringsSep(",", features)).str());
 
     /* Read the first line of input, which should be a word indicating
        whether the hook wishes to perform the build. */
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index 9540720fe240..2d26fc66dafe 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -966,6 +966,17 @@ Strings tokenizeString(const string & s, const string & separators)
 }
 
 
+string concatStringsSep(const string & sep, const Strings & ss)
+{
+    string s;
+    foreach (Strings::const_iterator, i, ss) {
+        if (s.size() != 0) s += sep;
+        s += *i;
+    }
+    return s;
+}
+
+
 string statusToString(int status)
 {
     if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
diff --git a/src/libutil/util.hh b/src/libutil/util.hh
index c45ebc062ffa..27ad46904958 100644
--- a/src/libutil/util.hh
+++ b/src/libutil/util.hh
@@ -280,6 +280,11 @@ MakeError(Interrupted, BaseError)
 Strings tokenizeString(const string & s, const string & separators = " \t\n\r");
 
 
+/* Concatenate the given strings with a separator between the
+   elements. */
+string concatStringsSep(const string & sep, const Strings & ss);
+
+
 /* Convert the exit status of a child as returned by wait() into an
    error string. */
 string statusToString(int status);