about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-08-27T13·18+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-08-27T13·18+0000
commit766f7084188d8c0dd0595bbbfc50fbc4f9d67a50 (patch)
tree2860458de610cf2e9b39cca440332b789e44f240 /src/libstore/build.cc
parente41ecbf7303a181fd37026edb72f2f23dde7e73b (diff)
* Experimental feature: allow a derivation to tell the build hook that
  it requires a certain feature on the build machine, e.g.

    requiredSystemFeatures = [ "kvm" ];

  We need this in Hydra to make sure that builds that require KVM
  support are forwarded to machines that have KVM support.  Probably
  this should also be enforced for local builds.

Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc12
1 files changed, 10 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. */