diff --git a/doc/manual/command-ref/conf-file.xml b/doc/manual/command-ref/conf-file.xml
index 6952829e8..3de9647aa 100644
--- a/doc/manual/command-ref/conf-file.xml
+++ b/doc/manual/command-ref/conf-file.xml
@@ -334,16 +334,6 @@ flag, e.g. --option gc-keep-outputs false.
- use-binary-caches
-
- If set to true (the default),
- Nix will check the binary caches specified by
- and related options to obtain
- binary substitutes.
-
-
-
-
binary-caches
A list of URLs of binary caches, separated by
diff --git a/perl/lib/Nix/Config.pm.in b/perl/lib/Nix/Config.pm.in
index f494e34a5..4bdee7fd8 100644
--- a/perl/lib/Nix/Config.pm.in
+++ b/perl/lib/Nix/Config.pm.in
@@ -20,22 +20,15 @@ $useBindings = 1;
%config = ();
sub readConfig {
- if (defined $ENV{'_NIX_OPTIONS'}) {
- foreach my $s (split '\n', $ENV{'_NIX_OPTIONS'}) {
- my ($n, $v) = split '=', $s, 2;
- $config{$n} = $v;
- }
- } else {
- my $config = "$confDir/nix.conf";
- return unless -f $config;
+ my $config = "$confDir/nix.conf";
+ return unless -f $config;
- open CONFIG, "<$config" or die "cannot open ‘$config’";
- while () {
- /^\s*([\w\-\.]+)\s*=\s*(.*)$/ or next;
- $config{$1} = $2;
- }
- close CONFIG;
+ open CONFIG, "<$config" or die "cannot open ‘$config’";
+ while () {
+ /^\s*([\w\-\.]+)\s*=\s*(.*)$/ or next;
+ $config{$1} = $2;
}
+ close CONFIG;
}
return 1;
diff --git a/src/libmain/common-args.cc b/src/libmain/common-args.cc
index 98693d78a..9a7a89313 100644
--- a/src/libmain/common-args.cc
+++ b/src/libmain/common-args.cc
@@ -22,7 +22,11 @@ MixCommonArgs::MixCommonArgs(const string & programName)
[](Strings ss) {
auto name = ss.front(); ss.pop_front();
auto value = ss.front();
- settings.set(name, value);
+ try {
+ settings.set(name, value);
+ } catch (UsageError & e) {
+ warn(e.what());
+ }
});
}
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index c1828aa7d..9d506d019 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -138,9 +138,6 @@ void initNix()
struct timeval tv;
gettimeofday(&tv, 0);
srandom(tv.tv_usec);
-
- if (char *pack = getenv("_NIX_OPTIONS"))
- settings.unpack(pack);
}
@@ -156,10 +153,10 @@ struct LegacyArgs : public MixCommonArgs
&settings.verboseBuild, false);
mkFlag('K', "keep-failed", "keep temporary directories of failed builds",
- &settings.keepFailed);
+ &(bool&) settings.keepFailed);
mkFlag('k', "keep-going", "keep going after a build fails",
- &settings.keepGoing);
+ &(bool&) settings.keepGoing);
mkFlag(0, "fallback", "build from source if substitution fails", []() {
settings.set("build-fallback", "true");
@@ -184,7 +181,7 @@ struct LegacyArgs : public MixCommonArgs
&settings.readOnlyMode);
mkFlag(0, "no-build-hook", "disable use of the build hook mechanism",
- &settings.useBuildHook, false);
+ &(bool&) settings.useBuildHook, false);
mkFlag(0, "show-trace", "show Nix expression stack trace in evaluation errors",
&settings.showTrace);
@@ -218,7 +215,6 @@ void parseCmdLine(int argc, char * * argv,
std::function parseArg)
{
LegacyArgs(baseNameOf(argv[0]), parseArg).parseCmdline(argvToStrings(argc, argv));
- settings.update();
}
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index b23447fa0..33c9e3704 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -462,7 +462,7 @@ UserLock::UserLock()
assert(settings.buildUsersGroup != "");
/* Get the members of the build-users-group. */
- struct group * gr = getgrnam(settings.buildUsersGroup.c_str());
+ struct group * gr = getgrnam(settings.buildUsersGroup.get().c_str());
if (!gr)
throw Error(format("the group ‘%1%’ specified in ‘build-users-group’ does not exist")
% settings.buildUsersGroup);
@@ -1690,10 +1690,7 @@ void DerivationGoal::startBuilder()
/* Are we doing a chroot build? */
{
- string x = settings.useSandbox;
- if (x != "true" && x != "false" && x != "relaxed")
- throw Error("option ‘build-use-sandbox’ must be set to one of ‘true’, ‘false’ or ‘relaxed’");
- if (x == "true") {
+ if (settings.sandboxMode == smEnabled) {
if (get(drv->env, "__noChroot") == "1")
throw Error(format("derivation ‘%1%’ has ‘__noChroot’ set, "
"but that's not allowed when ‘build-use-sandbox’ is ‘true’") % drvPath);
@@ -1704,9 +1701,9 @@ void DerivationGoal::startBuilder()
#endif
useChroot = true;
}
- else if (x == "false")
+ else if (settings.sandboxMode == smDisabled)
useChroot = false;
- else if (x == "relaxed")
+ else if (settings.sandboxMode == smRelaxed)
useChroot = !fixedOutput && get(drv->env, "__noChroot") != "1";
}
diff --git a/src/libstore/crypto.cc b/src/libstore/crypto.cc
index 9692dd83b..f56a6adab 100644
--- a/src/libstore/crypto.cc
+++ b/src/libstore/crypto.cc
@@ -105,12 +105,12 @@ PublicKeys getDefaultPublicKeys()
// FIXME: filter duplicates
- for (auto s : settings.binaryCachePublicKeys) {
+ for (auto s : settings.binaryCachePublicKeys.get()) {
PublicKey key(s);
publicKeys.emplace(key.name, key);
}
- for (auto secretKeyFile : settings.secretKeyFiles) {
+ for (auto secretKeyFile : settings.secretKeyFiles.get()) {
try {
SecretKey secretKey(readFile(secretKeyFile));
publicKeys.emplace(secretKey.name, secretKey.toPublicKey());
diff --git a/src/libstore/download.cc b/src/libstore/download.cc
index 95e6f7bac..d073e870b 100644
--- a/src/libstore/download.cc
+++ b/src/libstore/download.cc
@@ -251,7 +251,7 @@ struct CurlDownloader : public Downloader
/* If no file exist in the specified path, curl continues to work
anyway as if netrc support was disabled. */
- curl_easy_setopt(req, CURLOPT_NETRC_FILE, settings.netrcFile.c_str());
+ curl_easy_setopt(req, CURLOPT_NETRC_FILE, settings.netrcFile.get().c_str());
curl_easy_setopt(req, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
result.data = std::make_shared();
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index b9f4fada5..bb61daa51 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -1,6 +1,7 @@
#include "globals.hh"
#include "util.hh"
#include "archive.hh"
+#include "args.hh"
#include
#include