daemon: Change some options via 'settings.set'.

* nix/nix-daemon/guix-daemon.cc (parse_opt): Use 'settings.set' instead
  of direct field access for 'buildCores', 'maxBuildJobs', and
  'useSubstitutes'.
  (main): Call 'settings.update' after 'argp_parse'.
This commit is contained in:
Ludovic Courtès 2014-03-27 22:08:53 +01:00
parent 15f682f4a3
commit ad0ab74eef

View file

@ -187,7 +187,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
} }
break; break;
case GUIX_OPT_NO_SUBSTITUTES: case GUIX_OPT_NO_SUBSTITUTES:
settings.useSubstitutes = false; settings.set ("build-use-substitutes", "false");
break; break;
case GUIX_OPT_NO_BUILD_HOOK: case GUIX_OPT_NO_BUILD_HOOK:
settings.useBuildHook = false; settings.useBuildHook = false;
@ -202,10 +202,10 @@ parse_opt (int key, char *arg, struct argp_state *state)
settings.gcKeepDerivations = string_to_bool (arg); settings.gcKeepDerivations = string_to_bool (arg);
break; break;
case 'c': case 'c':
settings.buildCores = atoi (arg); settings.set ("build-cores", arg);
break; break;
case 'M': case 'M':
settings.maxBuildJobs = atoi (arg); settings.set ("build-max-jobs", arg);
break; break;
case GUIX_OPT_SYSTEM: case GUIX_OPT_SYSTEM:
settings.thisSystem = arg; settings.thisSystem = arg;
@ -263,7 +263,7 @@ main (int argc, char *argv[])
/* Use our substituter by default. */ /* Use our substituter by default. */
settings.substituters.clear (); settings.substituters.clear ();
settings.useSubstitutes = true; settings.set ("build-use-substitutes", "true");
#ifdef HAVE_DAEMON_OFFLOAD_HOOK #ifdef HAVE_DAEMON_OFFLOAD_HOOK
/* Use our build hook for distributed builds by default. */ /* Use our build hook for distributed builds by default. */
@ -282,6 +282,9 @@ main (int argc, char *argv[])
argp_parse (&argp, argc, argv, 0, 0, 0); argp_parse (&argp, argc, argv, 0, 0, 0);
/* Effect all the changes made via 'settings.set'. */
settings.update ();
if (settings.useSubstitutes) if (settings.useSubstitutes)
{ {
string subs = getEnv ("NIX_SUBSTITUTERS", "default"); string subs = getEnv ("NIX_SUBSTITUTERS", "default");