diff options
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/derivations.cc | 30 | ||||
-rw-r--r-- | src/libstore/derivations.hh | 2 | ||||
-rw-r--r-- | src/libstore/local-store.hh | 3 | ||||
-rw-r--r-- | src/libstore/store-api.cc | 20 |
4 files changed, 21 insertions, 34 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index f325e511a..67565a704 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -128,7 +128,7 @@ static DerivationOutput parseDerivationOutput(const Store & store, std::istrings } -static Derivation parseDerivation(const Store & store, std::string && s) +Derivation parseDerivation(const Store & store, std::string && s) { Derivation drv; std::istringstream str(std::move(s)); @@ -174,34 +174,6 @@ static Derivation parseDerivation(const Store & store, std::string && s) } -Derivation readDerivation(const Store & store, const Path & drvPath) -{ - try { - return parseDerivation(store, readFile(drvPath)); - } catch (FormatError & e) { - throw Error("error parsing derivation '%1%': %2%", drvPath, e.msg()); - } -} - - -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()); - } -} - - static void printString(string & res, std::string_view s) { char buf[s.size() * 2 + 2]; diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh index 68c53c1ff..d32793b6a 100644 --- a/src/libstore/derivations.hh +++ b/src/libstore/derivations.hh @@ -76,7 +76,7 @@ StorePath writeDerivation(ref<Store> store, const Derivation & drv, std::string_view name, RepairFlag repair = NoRepair); /* Read a derivation from a file. */ -Derivation readDerivation(const Store & store, const Path & drvPath); +Derivation parseDerivation(const Store & store, string && s); // FIXME: remove bool isDerivation(const string & fileName); diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh index c0e5d0286..05f342902 100644 --- a/src/libstore/local-store.hh +++ b/src/libstore/local-store.hh @@ -23,9 +23,6 @@ namespace nix { const int nixSchemaVersion = 10; -struct Derivation; - - struct OptimiseStats { unsigned long filesLinked = 0; diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 5b9f79049..5b0b33046 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 "archive.hh" @@ -871,6 +871,24 @@ Strings ValidPathInfo::shortRefs() const } +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()); + } +} + + } |