From 18493fd9c48676ab26854739db67ac5d76ff9347 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 17 Jun 2020 03:56:48 +0000 Subject: 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. --- src/libstore/derivations.cc | 31 +------------------------------ 1 file changed, 1 insertion(+), 30 deletions(-) (limited to 'src/libstore/derivations.cc') diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index b95f7bfdc..ea30813fa 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -3,7 +3,6 @@ #include "globals.hh" #include "util.hh" #include "worker-protocol.hh" -#include "fs-accessor.hh" #include "istringstream_nocopy.hh" namespace nix { @@ -120,7 +119,7 @@ static StringSet parseStrings(std::istream & str, bool arePaths) } -static Derivation parseDerivation(const Store & store, const string & s) +Derivation parseDerivation(const Store & store, const string & s) { Derivation drv; istringstream_nocopy str(s); @@ -173,34 +172,6 @@ static Derivation parseDerivation(const Store & store, const 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]; -- cgit v1.2.3 From 35e6288be1a2384a29caccd64d88a6b623e6c033 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 23 Aug 2020 15:00:25 +0000 Subject: `writeDerivation` just needs a plain store reference --- src/libstore/derivations.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/libstore/derivations.cc') diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc index a9fed2564..43bc61e55 100644 --- a/src/libstore/derivations.cc +++ b/src/libstore/derivations.cc @@ -61,7 +61,7 @@ bool BasicDerivation::isBuiltin() const } -StorePath writeDerivation(ref store, +StorePath writeDerivation(Store & store, const Derivation & drv, RepairFlag repair) { auto references = drv.inputSrcs; @@ -71,10 +71,10 @@ StorePath writeDerivation(ref store, (that can be missing (of course) and should not necessarily be held during a garbage collection). */ auto suffix = std::string(drv.name) + drvExtension; - auto contents = drv.unparse(*store, false); + auto contents = drv.unparse(store, false); return settings.readOnlyMode - ? store->computeStorePathForText(suffix, contents, references) - : store->addTextToStore(suffix, contents, references, repair); + ? store.computeStorePathForText(suffix, contents, references) + : store.addTextToStore(suffix, contents, references, repair); } -- cgit v1.2.3