about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-02-02T17·24+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-02-02T17·24+0000
commitb682fae9d93037af65282e02b88a9ce34129026e (patch)
tree2e349a7480d315561bf40864e405b51f9c3ee16d /src/libstore/build.cc
parent6f8c96d12399b747b5f41b5211a635d2801247c8 (diff)
* Build hooks: use nix-store --import. This prevents a redundant
  scan for runtime dependencies (i.e. the local machine shouldn't do a
  scan that the remote machine has already done).  Also pipe directly
  into `nix-store --import': don't use a temporary file.

Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 6b1bc55f95..d44dcf0ff0 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1240,6 +1240,12 @@ DerivationGoal::HookReply DerivationGoal::tryBuildHook()
 
             initChild();
 
+            string s;
+            foreach (DerivationOutputs::const_iterator, i, drv.outputs)
+                s += i->second.path + " ";
+            if (setenv("NIX_HELD_LOCKS", s.c_str(), 1))
+                throw SysError("setting an environment variable");
+
             execl(buildHook.c_str(), buildHook.c_str(),
                 (worker.canBuildMore() ? (string) "1" : "0").c_str(),
                 thisSystem.c_str(),
@@ -1945,13 +1951,21 @@ void DerivationGoal::computeClosure()
 {
     map<Path, PathSet> allReferences;
     map<Path, Hash> contentHashes;
-    
+
+    /* When using a build hook, the build hook can register the output
+       as valid (by doing `nix-store --import').  If so we don't have
+       to do anything here. */
+    if (usingBuildHook) {
+        bool allValid = true;
+        foreach (DerivationOutputs::iterator, i, drv.outputs)
+            if (!worker.store.isValidPath(i->second.path)) allValid = false;
+        if (allValid) return;
+    }
+        
     /* Check whether the output paths were created, and grep each
        output path to determine what other paths it references.  Also make all
        output paths read-only. */
-    for (DerivationOutputs::iterator i = drv.outputs.begin(); 
-         i != drv.outputs.end(); ++i)
-    {
+    foreach (DerivationOutputs::iterator, i, drv.outputs) {
         Path path = i->second.path;
         if (!pathExists(path)) {
             throw BuildError(
@@ -2043,14 +2057,11 @@ void DerivationGoal::computeClosure()
        paths referenced by each of them.  !!! this should be
        atomic so that either all paths are registered as valid, or
        none are. */
-    for (DerivationOutputs::iterator i = drv.outputs.begin(); 
-         i != drv.outputs.end(); ++i)
-    {
+    foreach (DerivationOutputs::iterator, i, drv.outputs)
         worker.store.registerValidPath(i->second.path,
             contentHashes[i->second.path],
             allReferences[i->second.path],
             drvPath);
-    }
 
     /* It is now safe to delete the lock files, since all future
        lockers will see that the output paths are valid; they will not