diff options
author | Ludovic Courtès <ludo@gnu.org> | 2019-09-04 11:04:44 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2019-09-08 11:49:24 +0200 |
commit | f6919ebdc6b0ce0286814cc6ab0564b1a4c67f5f (patch) | |
tree | 6b9d4a206bc2f530756ad55935e7704fb54a6563 /nix/libstore/build.cc | |
parent | bc69ea2d605810cc32e13ed03d5848b8dc358b61 (diff) | |
download | guix-f6919ebdc6b0ce0286814cc6ab0564b1a4c67f5f.tar.gz |
daemon: Run 'guix substitute' directly and assume a single substituter.
The daemon had a mechanism that allows it to handle a list of substituters and try them sequentially; this removes it. * nix/scripts/substitute.in: Remove. * nix/local.mk (nodist_pkglibexec_SCRIPTS): Remove. * config-daemon.ac: Don't output 'nix/scripts/substitute'. * nix/libstore/build.cc (SubstitutionGoal)[subs, sub, hasSubstitute]: Remove. [tryNext]: Make private. (SubstitutionGoal::SubstitutionGoal, SubstitutionGoal::init): Remove now unneeded initializers. (SubstitutionGoal::tryNext): Adjust to assume a single substituter: call 'amDone' upfront when we couldn't find substitutes. (SubstitutionGoal::tryToRun): Adjust to run 'guix substitute' via 'settings.guixProgram'. (SubstitutionGoal::finished): Call 'amDone(ecFailed)' upon failure instead of setting 'state' to 'tryNext'. * nix/libstore/globals.hh (Settings)[substituters]: Remove. * nix/libstore/local-store.cc (LocalStore::~LocalStore): Adjust to handle a single substituter. (LocalStore::startSubstituter): Remove 'path' parameter. Adjust to invoke 'settings.guixProgram'. Don't refer to 'run.program', which no longer exists. (LocalStore::querySubstitutablePaths): Adjust for 'runningSubstituters' being a singleton instead of a list. (LocalStore::querySubstitutablePathInfos): Likewise, and remove 'substituter' parameter. * nix/libstore/local-store.hh (RunningSubstituter)[program]: Remove. (LocalStore)[runningSubstituters]: Remove. [runningSubstituter]: New field. [querySubstitutablePathInfos]: Remove 'substituter' parameter. [startSubstituter]: Remove 'substituter' parameter. * nix/nix-daemon/guix-daemon.cc (main): Remove references to 'settings.substituters'. * nix/nix-daemon/nix-daemon.cc (performOp): Ignore the user's "build-use-substitutes" value when 'settings.useSubstitutes' is false.
Diffstat (limited to 'nix/libstore/build.cc')
-rw-r--r-- | nix/libstore/build.cc | 52 |
1 files changed, 19 insertions, 33 deletions
diff --git a/nix/libstore/build.cc b/nix/libstore/build.cc index 9f1f88933a..ad53b81413 100644 --- a/nix/libstore/build.cc +++ b/nix/libstore/build.cc @@ -2863,15 +2863,6 @@ private: /* The store path that should be realised through a substitute. */ Path storePath; - /* The remaining substituters. */ - Paths subs; - - /* The current substituter. */ - Path sub; - - /* Whether any substituter can realise this path */ - bool hasSubstitute; - /* Path info returned by the substituter's query info operation. */ SubstitutablePathInfo info; @@ -2897,6 +2888,8 @@ private: typedef void (SubstitutionGoal::*GoalState)(); GoalState state; + void tryNext(); + public: SubstitutionGoal(const Path & storePath, Worker & worker, bool repair = false); ~SubstitutionGoal(); @@ -2914,7 +2907,6 @@ public: /* The states. */ void init(); - void tryNext(); void gotInfo(); void referencesValid(); void tryToRun(); @@ -2930,7 +2922,6 @@ public: SubstitutionGoal::SubstitutionGoal(const Path & storePath, Worker & worker, bool repair) : Goal(worker) - , hasSubstitute(false) , repair(repair) { this->storePath = storePath; @@ -2980,37 +2971,31 @@ void SubstitutionGoal::init() if (settings.readOnlyMode) throw Error(format("cannot substitute path `%1%' - no write access to the store") % storePath); - subs = settings.substituters; - tryNext(); } void SubstitutionGoal::tryNext() { - trace("trying next substituter"); + trace("trying substituter"); - if (subs.size() == 0) { + SubstitutablePathInfos infos; + PathSet dummy(singleton<PathSet>(storePath)); + worker.store.querySubstitutablePathInfos(dummy, infos); + SubstitutablePathInfos::iterator k = infos.find(storePath); + if (k == infos.end()) { /* None left. Terminate this goal and let someone else deal with it. */ debug(format("path `%1%' is required, but there is no substituter that can build it") % storePath); /* Hack: don't indicate failure if there were no substituters. In that case the calling derivation should just do a build. */ - amDone(hasSubstitute ? ecFailed : ecNoSubstituters); - return; + amDone(ecNoSubstituters); + return; } - sub = subs.front(); - subs.pop_front(); - - SubstitutablePathInfos infos; - PathSet dummy(singleton<PathSet>(storePath)); - worker.store.querySubstitutablePathInfos(sub, dummy, infos); - SubstitutablePathInfos::iterator k = infos.find(storePath); - if (k == infos.end()) { tryNext(); return; } + /* Found a substitute. */ info = k->second; - hasSubstitute = true; /* To maintain the closure invariant, we first have to realise the paths referenced by this one. */ @@ -3098,7 +3083,8 @@ void SubstitutionGoal::tryToRun() /* Fill in the arguments. */ Strings args; - args.push_back(baseNameOf(sub)); + args.push_back("guix"); + args.push_back("substitute"); args.push_back("--substitute"); args.push_back(storePath); args.push_back(destPath); @@ -3111,9 +3097,9 @@ void SubstitutionGoal::tryToRun() if (dup2(outPipe.writeSide, STDOUT_FILENO) == -1) throw SysError("cannot dup output pipe into stdout"); - execv(sub.c_str(), stringsToCharPtrs(args).data()); + execv(settings.guixProgram.c_str(), stringsToCharPtrs(args).data()); - throw SysError(format("executing `%1%'") % sub); + throw SysError(format("executing `%1% substitute'") % settings.guixProgram); }); pid.setSeparatePG(true); @@ -3126,7 +3112,9 @@ void SubstitutionGoal::tryToRun() state = &SubstitutionGoal::finished; if (settings.printBuildTrace) - printMsg(lvlError, format("@ substituter-started %1% %2%") % storePath % sub); + /* The second element in the message used to be the name of the + substituter but we're left with only one. */ + printMsg(lvlError, format("@ substituter-started %1% substitute") % storePath); } @@ -3192,9 +3180,7 @@ void SubstitutionGoal::finished() % storePath % status % e.msg()); } - /* Try the next substitute. */ - state = &SubstitutionGoal::tryNext; - worker.wakeUp(shared_from_this()); + amDone(ecFailed); return; } |