diff options
Diffstat (limited to 'src/libstore/derivations.cc')
-rw-r--r-- | src/libstore/derivations.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index 8067e412a..5590b99b3 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 += '"'; |