about summary refs log tree commit diff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-06-27T20·58-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-06-27T20·58-0400
commit1aba0bf0fa831ffee628ae50730eade5b19a544f (patch)
tree802eb8026a8357d87123a73fc49282381b5fd734 /src/libstore
parent42f5a2fc297f841d982f07062c653b27557a3cd5 (diff)
nix-store -r: do substitutions in parallel
I.e. when multiple non-derivation arguments are passed to ‘nix-store
-r’ to be substituted, do them in parallel.
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc13
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/remote-store.cc4
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/store-api.hh8
-rw-r--r--src/libstore/worker-protocol.hh2
6 files changed, 19 insertions, 12 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 246e0d9da8..d5bbd540b3 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -2275,6 +2275,8 @@ public:
     /* Callback used by the worker to write to the log. */
     void handleChildOutput(int fd, const string & data);
     void handleEOF(int fd);
+
+    Path getStorePath() { return storePath; }
 };
 
 
@@ -2938,7 +2940,7 @@ unsigned int Worker::exitStatus()
 //////////////////////////////////////////////////////////////////////
 
 
-void LocalStore::buildDerivations(const PathSet & drvPaths)
+void LocalStore::buildPaths(const PathSet & drvPaths)
 {
     startNest(nest, lvlDebug,
         format("building %1%") % showPaths(drvPaths));
@@ -2947,7 +2949,10 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
 
     Goals goals;
     foreach (PathSet::const_iterator, i, drvPaths)
-        goals.insert(worker.makeDerivationGoal(*i));
+        if (isDerivation(*i))
+            goals.insert(worker.makeDerivationGoal(*i));
+        else
+            goals.insert(worker.makeSubstitutionGoal(*i));
 
     worker.run(goals);
 
@@ -2955,8 +2960,8 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
     foreach (Goals::iterator, i, goals)
         if ((*i)->getExitCode() == Goal::ecFailed) {
             DerivationGoal * i2 = dynamic_cast<DerivationGoal *>(i->get());
-            assert(i2);
-            failed.insert(i2->getDrvPath());
+            if (i2) failed.insert(i2->getDrvPath());
+            else failed.insert(dynamic_cast<SubstitutionGoal *>(i->get())->getStorePath());
         }
             
     if (!failed.empty())
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index 0ff3e7b39f..aa8e8582fb 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -150,7 +150,7 @@ public:
 
     Paths importPaths(bool requireSignature, Source & source);
     
-    void buildDerivations(const PathSet & drvPaths);
+    void buildPaths(const PathSet & paths);
 
     void ensurePath(const Path & path);
 
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index cbcf860543..5e5561a6ae 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -397,10 +397,10 @@ Paths RemoteStore::importPaths(bool requireSignature, Source & source)
 }
 
 
-void RemoteStore::buildDerivations(const PathSet & drvPaths)
+void RemoteStore::buildPaths(const PathSet & drvPaths)
 {
     openConnection();
-    writeInt(wopBuildDerivations, to);
+    writeInt(wopBuildPaths, to);
     writeStrings(drvPaths, to);
     processStderr();
     readInt(from);
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 823e694dd3..e9f40da6db 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -60,7 +60,7 @@ public:
 
     Paths importPaths(bool requireSignature, Source & source);
     
-    void buildDerivations(const PathSet & drvPaths);
+    void buildPaths(const PathSet & paths);
 
     void ensurePath(const Path & path);
 
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index fa766d12e1..bf3269f578 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -172,13 +172,15 @@ public:
        the Nix store. */
     virtual Paths importPaths(bool requireSignature, Source & source) = 0;
 
-    /* Ensure that the output paths of the derivation are valid.  If
+    /* For each path, if it's a derivation, build it.  Building a
+       derivation means ensuring that the output paths are valid.  If
        they are already valid, this is a no-op.  Otherwise, validity
        can be reached in two ways.  First, if the output paths is
        substitutable, then build the path that way.  Second, the
        output paths can be created by running the builder, after
-       recursively building any sub-derivations. */
-    virtual void buildDerivations(const PathSet & drvPaths) = 0;
+       recursively building any sub-derivations. For inputs that are
+       not derivations, substitute them. */
+    virtual void buildPaths(const PathSet & paths) = 0;
 
     /* Ensure that a path is valid.  If it is not currently valid, it
        may be made valid by running a substitute (if defined for the
diff --git a/src/libstore/worker-protocol.hh b/src/libstore/worker-protocol.hh
index c1ea7f7584..6a5f0ed40d 100644
--- a/src/libstore/worker-protocol.hh
+++ b/src/libstore/worker-protocol.hh
@@ -22,7 +22,7 @@ typedef enum {
     wopQueryReferrers = 6,
     wopAddToStore = 7,
     wopAddTextToStore = 8,
-    wopBuildDerivations = 9,
+    wopBuildPaths = 9,
     wopEnsurePath = 10,
     wopAddTempRoot = 11,
     wopAddIndirectRoot = 12,