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.
This commit is contained in:
Ludovic Courtès 2019-09-04 11:04:44 +02:00
parent bc69ea2d60
commit f6919ebdc6
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5
9 changed files with 84 additions and 115 deletions

View file

@ -466,8 +466,7 @@ main (int argc, char *argv[])
{
settings.processEnvironment ();
/* Use our substituter by default. */
settings.substituters.clear ();
/* Enable substitutes by default. */
settings.set ("build-use-substitutes", "true");
/* Use our substitute server by default. */
@ -490,14 +489,6 @@ main (int argc, char *argv[])
printMsg(lvlDebug,
format ("build log compression: %1%") % settings.logCompression);
if (settings.useSubstitutes)
settings.substituters.push_back (settings.nixLibexecDir
+ "/substitute");
else
/* Clear the substituter list to make sure nothing ever gets
substituted, regardless of the client's settings. */
settings.substituters.clear ();
if (geteuid () == 0 && settings.buildUsersGroup.empty ())
fprintf (stderr, _("warning: daemon is running as root, so \
using `--build-users-group' is highly recommended\n"));

View file

@ -596,8 +596,12 @@ static void performOp(bool trusted, unsigned int clientVersion,
if (GET_PROTOCOL_MINOR(clientVersion) >= 6
&& GET_PROTOCOL_MINOR(clientVersion) < 0x61)
settings.set("build-cores", std::to_string(readInt(from)));
if (GET_PROTOCOL_MINOR(clientVersion) >= 10)
settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
if (GET_PROTOCOL_MINOR(clientVersion) >= 10) {
if (settings.useSubstitutes)
settings.set("build-use-substitutes", readInt(from) ? "true" : "false");
else
readInt(from); // substitutes remain disabled
}
if (GET_PROTOCOL_MINOR(clientVersion) >= 12) {
unsigned int n = readInt(from);
for (unsigned int i = 0; i < n; i++) {