about summary refs log tree commit diff
path: root/src/libstore/derivations.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-02T16·43+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-02T16·43+0200
commitd64e0c1b64dc20b02fae335397213d1ca17d9d56 (patch)
treef667d3e2249ed3b8240c7a48e895fb540c3be550 /src/libstore/derivations.cc
parenteda2aaae92c54892e70fff2958698e68a8204d35 (diff)
Make derivationFromPath work on diverted stores
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r--src/libstore/derivations.cc14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index 8067e412ad..5590b99b36 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -3,6 +3,7 @@
 #include "globals.hh"
 #include "util.hh"
 #include "worker-protocol.hh"
+#include "fs-accessor.hh"
 
 
 namespace nix {
@@ -164,6 +165,19 @@ Derivation readDerivation(const Path & drvPath)
 }
 
 
+Derivation Store::derivationFromPath(const Path & drvPath)
+{
+    assertStorePath(drvPath);
+    ensurePath(drvPath);
+    auto accessor = getFSAccessor();
+    try {
+        return parseDerivation(accessor->readFile(drvPath));
+    } catch (FormatError & e) {
+        throw Error(format("error parsing derivation ‘%1%’: %2%") % drvPath % e.msg());
+    }
+}
+
+
 static void printString(string & res, const string & s)
 {
     res += '"';