diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 5bd745454abe9c1af1709964246ce7e6023735ac..21bf7167e5238686c187c0218ed9f1daeda96038 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1187,15 +1187,6 @@ void DerivationGoal::inputsRealised()
 }
 
 
-PathSet outputPaths(const DerivationOutputs & outputs)
-{
-    PathSet paths;
-    foreach (DerivationOutputs::const_iterator, i, outputs)
-        paths.insert(i->second.path);
-    return paths;
-}
-
-
 static bool canBuildLocally(const string & platform)
 {
     return platform == settings.thisSystem
@@ -1247,7 +1238,7 @@ void DerivationGoal::tryToBuild()
        can't acquire the lock, then continue; hopefully some other
        goal can start a build, and if not, the main loop will sleep a
        few seconds and then retry this goal. */
-    if (!outputLocks.lockPaths(outputPaths(drv.outputs), "", false)) {
+    if (!outputLocks.lockPaths(outputPaths(drv), "", false)) {
         worker.waitForAWhile(shared_from_this());
         return;
     }
@@ -1268,7 +1259,7 @@ void DerivationGoal::tryToBuild()
         return;
     }
 
-    missingPaths = outputPaths(drv.outputs);
+    missingPaths = outputPaths(drv);
     if (buildMode != bmCheck)
         foreach (PathSet::iterator, i, validPaths) missingPaths.erase(*i);
 
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 7234ae5630edbf6f2d1612e86767c2be3fa4c2c2..fbc1d99f3d6f6e3e220d4978d772c4af0d5b6323 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -285,4 +285,13 @@ bool wantOutput(const string & output, const std::set<string> & wanted)
 }
 
 
+PathSet outputPaths(const Derivation & drv)
+{
+    PathSet paths;
+    for (auto & i : drv.outputs)
+        paths.insert(i.second.path);
+    return paths;
+}
+
+
 }
diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh
index 04b64dfc88a7f9f519d627f4e44b6e925334e0d1..8d5e4d05d469e0d0ab6dd66ccaabc6faa6ccfd70 100644
--- a/src/libstore/derivations.hh
+++ b/src/libstore/derivations.hh
@@ -89,5 +89,6 @@ Path makeDrvPathWithOutputs(const Path & drvPath, const std::set<string> & outpu
 
 bool wantOutput(const string & output, const std::set<string> & wanted);
 
+PathSet outputPaths(const Derivation & drv);
 
 }