diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-06-02T16·43+0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2016-06-02T16·43+0200 |
commit | d64e0c1b64dc20b02fae335397213d1ca17d9d56 (patch) | |
tree | f667d3e2249ed3b8240c7a48e895fb540c3be550 /src/libstore/derivations.cc | |
parent | eda2aaae92c54892e70fff2958698e68a8204d35 (diff) |
Make derivationFromPath work on diverted stores
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 8067e412adf2..5590b99b36fa 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 += '"'; |