diff options
author | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-17 03:56:48 +0000 |
---|---|---|
committer | John Ericson <John.Ericson@Obsidian.Systems> | 2020-06-17 04:30:16 +0000 |
commit | 18493fd9c48676ab26854739db67ac5d76ff9347 (patch) | |
tree | c312242c7679cd4b118f08d292eb70bd362bf8a5 /src/libstore/store-api.cc | |
parent | 7130f0a3a6455cf27863f0bbccf0974cfcc82fa2 (diff) |
Move some Store functions from derivations.cc to store-api.cc
This further continues with the dependency inverstion. Also I just went
ahead and exposed `parseDerivation`: it seems like the more proper
building block, and not a bad thing to expose if we are trying to be
less wedded to drv files on disk anywas.
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r-- | src/libstore/store-api.cc | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index aae227bae..0147445ff 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -1,11 +1,11 @@ #include "crypto.hh" +#include "fs-accessor.hh" #include "globals.hh" #include "store-api.hh" #include "util.hh" #include "nar-info-disk-cache.hh" #include "thread-pool.hh" #include "json.hh" -#include "derivations.hh" #include "url.hh" #include <future> @@ -821,6 +821,24 @@ std::string makeFixedOutputCA(FileIngestionMethod recursive, const Hash & hash) } +Derivation Store::derivationFromPath(const StorePath & drvPath) +{ + ensurePath(drvPath); + return readDerivation(drvPath); +} + + +Derivation Store::readDerivation(const StorePath & drvPath) +{ + auto accessor = getFSAccessor(); + try { + return parseDerivation(*this, accessor->readFile(printStorePath(drvPath))); + } catch (FormatError & e) { + throw Error("error parsing derivation '%s': %s", printStorePath(drvPath), e.msg()); + } +} + + } |