diff --git a/src/hydra-eval-jobs/hydra-eval-jobs.cc b/src/hydra-eval-jobs/hydra-eval-jobs.cc index 1fe94874..237d174a 100644 --- a/src/hydra-eval-jobs/hydra-eval-jobs.cc +++ b/src/hydra-eval-jobs/hydra-eval-jobs.cc @@ -153,7 +153,7 @@ static void findJobsWrapped(EvalState & state, JSONObject & top, done. */ if (gcRootsDir != "") { Path root = gcRootsDir + "/" + baseNameOf(drvPath); - if (!pathExists(root)) addPermRoot(*store, drvPath, root, false); + if (!pathExists(root)) state.store->addPermRoot(drvPath, root, false); } res.attr("outputs"); @@ -253,7 +253,7 @@ int main(int argc, char * * argv) if (gcRootsDir == "") printMsg(lvlError, "warning: `--gc-roots-dir' not specified"); - EvalState state(searchPath); + EvalState state(searchPath, openStore()); AutoArgs autoArgs; Value * inputsSet = state.allocValue(); @@ -280,8 +280,6 @@ int main(int argc, char * * argv) autoArgs[sInputs].push_back(inputsSet); } - store = openStore(); - Value v; state.evalFile(releaseExpr, v); diff --git a/src/hydra-queue-runner/build-remote.cc b/src/hydra-queue-runner/build-remote.cc index cb6c0488..39d041d9 100644 --- a/src/hydra-queue-runner/build-remote.cc +++ b/src/hydra-queue-runner/build-remote.cc @@ -4,7 +4,6 @@ #include #include -#include "misc.hh" #include "serve-protocol.hh" #include "state.hh" #include "util.hh" @@ -74,14 +73,14 @@ static void openConnection(Machine::ptr machine, Path tmpDir, int stderrFD, Chil } -static void copyClosureTo(std::shared_ptr store, +static void copyClosureTo(ref store, FdSource & from, FdSink & to, const PathSet & paths, counter & bytesSent, bool useSubstitutes = false) { PathSet closure; for (auto & path : paths) - computeFSClosure(*store, path, closure); + store->computeFSClosure(path, closure); /* Send the "query valid paths" command with the "lock" option enabled. This prevents a race where the remote host @@ -96,7 +95,7 @@ static void copyClosureTo(std::shared_ptr store, if (present.size() == closure.size()) return; - Paths sorted = topoSortPaths(*store, closure); + Paths sorted = store->topoSortPaths(closure); Paths missing; for (auto i = sorted.rbegin(); i != sorted.rend(); ++i) @@ -108,7 +107,7 @@ static void copyClosureTo(std::shared_ptr store, bytesSent += store->queryPathInfo(p).narSize; to << cmdImportPaths; - exportPaths(*store, missing, false, to); + store->exportPaths(missing, false, to); to.flush(); if (readInt(from) != 1) @@ -116,7 +115,7 @@ static void copyClosureTo(std::shared_ptr store, } -static void copyClosureFrom(std::shared_ptr store, +static void copyClosureFrom(ref store, FdSource & from, FdSink & to, const PathSet & paths, counter & bytesReceived) { to << cmdExportPaths << 0 << paths; @@ -128,7 +127,7 @@ static void copyClosureFrom(std::shared_ptr store, } -void State::buildRemote(std::shared_ptr store, +void State::buildRemote(ref store, Machine::ptr machine, Step::ptr step, unsigned int maxSilentTime, unsigned int buildTimeout, RemoteResult & result) diff --git a/src/hydra-queue-runner/build-result.cc b/src/hydra-queue-runner/build-result.cc index 5f516d23..ebf07035 100644 --- a/src/hydra-queue-runner/build-result.cc +++ b/src/hydra-queue-runner/build-result.cc @@ -1,6 +1,5 @@ #include "build-result.hh" #include "store-api.hh" -#include "misc.hh" #include "util.hh" #include "regex.hh" @@ -22,7 +21,7 @@ static std::tuple secureRead(Path fileName) } -BuildOutput getBuildOutput(std::shared_ptr store, const Derivation & drv) +BuildOutput getBuildOutput(nix::ref store, const Derivation & drv) { BuildOutput res; @@ -32,7 +31,7 @@ BuildOutput getBuildOutput(std::shared_ptr store, const Derivation & d outputs.insert(output.second.path); PathSet closure; for (auto & output : outputs) - computeFSClosure(*store, output, closure); + store->computeFSClosure(output, closure); for (auto & path : closure) { auto info = store->queryPathInfo(path); res.closureSize += info.narSize; diff --git a/src/hydra-queue-runner/build-result.hh b/src/hydra-queue-runner/build-result.hh index e40e7dcd..7fdd659b 100644 --- a/src/hydra-queue-runner/build-result.hh +++ b/src/hydra-queue-runner/build-result.hh @@ -37,4 +37,4 @@ struct BuildOutput std::map metrics; }; -BuildOutput getBuildOutput(std::shared_ptr store, const nix::Derivation & drv); +BuildOutput getBuildOutput(nix::ref store, const nix::Derivation & drv); diff --git a/src/hydra-queue-runner/builder.cc b/src/hydra-queue-runner/builder.cc index eef6ab50..9d1fd0dc 100644 --- a/src/hydra-queue-runner/builder.cc +++ b/src/hydra-queue-runner/builder.cc @@ -45,7 +45,7 @@ void State::builder(MachineReservation::ptr reservation) } -bool State::doBuildStep(std::shared_ptr store, Step::ptr step, +bool State::doBuildStep(nix::ref store, Step::ptr step, Machine::ptr machine) { { @@ -354,7 +354,7 @@ bool State::doBuildStep(std::shared_ptr store, Step::ptr step, /* Remember failed paths in the database so that they won't be built again. */ if (!cachedFailure && result.status == BuildResult::PermanentFailure) - for (auto & path : outputPaths(step->drv)) + for (auto & path : step->drv.outputPaths()) txn.parameterized("insert into FailedPaths values ($1)")(path).exec(); txn.commit(); diff --git a/src/hydra-queue-runner/hydra-queue-runner.cc b/src/hydra-queue-runner/hydra-queue-runner.cc index 582a06ea..4d1146f5 100644 --- a/src/hydra-queue-runner/hydra-queue-runner.cc +++ b/src/hydra-queue-runner/hydra-queue-runner.cc @@ -359,7 +359,7 @@ void State::markSucceededBuild(pqxx::work & txn, Build::ptr build, bool State::checkCachedFailure(Step::ptr step, Connection & conn) { pqxx::work txn(conn); - for (auto & path : outputPaths(step->drv)) + for (auto & path : step->drv.outputPaths()) if (!txn.parameterized("select 1 from FailedPaths where path = $1")(path).exec().empty()) return true; return false; diff --git a/src/hydra-queue-runner/queue-monitor.cc b/src/hydra-queue-runner/queue-monitor.cc index be8d5137..bf96f489 100644 --- a/src/hydra-queue-runner/queue-monitor.cc +++ b/src/hydra-queue-runner/queue-monitor.cc @@ -1,7 +1,6 @@ #include "state.hh" #include "build-result.hh" #include "globals.hh" -#include "misc.hh" using namespace nix; @@ -64,7 +63,7 @@ void State::queueMonitorLoop() } -bool State::getQueuedBuilds(Connection & conn, std::shared_ptr store, unsigned int & lastBuildId) +bool State::getQueuedBuilds(Connection & conn, ref store, unsigned int & lastBuildId) { printMsg(lvlInfo, format("checking the queue for builds > %1%...") % lastBuildId); @@ -315,7 +314,7 @@ void State::processQueueChange(Connection & conn) } -Step::ptr State::createStep(std::shared_ptr store, +Step::ptr State::createStep(ref store, Connection & conn, Build::ptr build, const Path & drvPath, Build::ptr referringBuild, Step::ptr referringStep, std::set & finishedDrvs, std::set & newSteps, std::set & newRunnable) @@ -373,7 +372,7 @@ Step::ptr State::createStep(std::shared_ptr store, runnable while step->created == false. */ step->drv = readDerivation(drvPath); - step->preferLocalBuild = willBuildLocally(step->drv); + step->preferLocalBuild = step->drv.willBuildLocally(); step->systemType = step->drv.platform; { @@ -391,7 +390,7 @@ Step::ptr State::createStep(std::shared_ptr store, /* Are all outputs valid? */ bool valid = true; - PathSet outputs = outputPaths(step->drv); + PathSet outputs = step->drv.outputPaths(); DerivationOutputs missing; PathSet missingPaths; for (auto & i : step->drv.outputs) diff --git a/src/hydra-queue-runner/state.hh b/src/hydra-queue-runner/state.hh index e5fd8aae..a296ddc7 100644 --- a/src/hydra-queue-runner/state.hh +++ b/src/hydra-queue-runner/state.hh @@ -377,12 +377,12 @@ private: void queueMonitorLoop(); /* Check the queue for new builds. */ - bool getQueuedBuilds(Connection & conn, std::shared_ptr store, unsigned int & lastBuildId); + bool getQueuedBuilds(Connection & conn, nix::ref store, unsigned int & lastBuildId); /* Handle cancellation, deletion and priority bumps. */ void processQueueChange(Connection & conn); - Step::ptr createStep(std::shared_ptr store, + Step::ptr createStep(nix::ref store, Connection & conn, Build::ptr build, const nix::Path & drvPath, Build::ptr referringBuild, Step::ptr referringStep, std::set & finishedDrvs, std::set & newSteps, std::set & newRunnable); @@ -405,10 +405,10 @@ private: /* Perform the given build step. Return true if the step is to be retried. */ - bool doBuildStep(std::shared_ptr store, Step::ptr step, + bool doBuildStep(nix::ref store, Step::ptr step, Machine::ptr machine); - void buildRemote(std::shared_ptr store, + void buildRemote(nix::ref store, Machine::ptr machine, Step::ptr step, unsigned int maxSilentTime, unsigned int buildTimeout, RemoteResult & result);