aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-02-27 11:04:41 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-02-27 11:04:41 +0000
commit60cb7de336035768089cc764a3fd7e8867a8d298 (patch)
tree710ab85ccd7aa37f2df21ea5b37011273719273c /src
parent8ab6bc5a49686aedf85adffe322c4f016764af5f (diff)
* Allow options from the Nix config file to be overriden from the
command line (e.g. "--option build-use-chroot true").
Diffstat (limited to 'src')
-rw-r--r--src/libmain/shared.cc7
-rw-r--r--src/libstore/globals.cc12
-rw-r--r--src/libstore/globals.hh2
3 files changed, 21 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index cfb34d7eb..e080d8cc5 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -243,6 +243,13 @@ static void initAndRun(int argc, char * * argv)
maxSilentTime = getIntArg(arg, i, args.end());
else if (arg == "--no-build-hook")
useBuildHook = false;
+ else if (arg == "--option") {
+ ++i; if (i == args.end()) throw UsageError("`--option' requires two arguments");
+ string name = *i;
+ ++i; if (i == args.end()) throw UsageError("`--option' requires two arguments");
+ string value = *i;
+ overrideSetting(name, tokenizeString(value));
+ }
else remaining.push_back(arg);
}
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 296cc4ac8..907627b65 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -34,6 +34,9 @@ static bool settingsRead = false;
static std::map<string, Strings> settings;
+/* Overriden settings. */
+std::map<string, Strings> settingsCmdline;
+
string & at(Strings & ss, unsigned int n)
{
@@ -73,6 +76,8 @@ static void readSettings()
advance(i, 2);
settings[name] = Strings(i, tokens.end());
};
+
+ settings.insert(settingsCmdline.begin(), settingsCmdline.end());
settingsRead = true;
}
@@ -118,6 +123,13 @@ unsigned int queryIntSetting(const string & name, unsigned int def)
}
+void overrideSetting(const string & name, const Strings & value)
+{
+ if (settingsRead) settings[name] = value;
+ settingsCmdline[name] = value;
+}
+
+
void reloadSettings()
{
settingsRead = false;
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index b8e2bae66..687247cc7 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -101,6 +101,8 @@ bool queryBoolSetting(const string & name, bool def);
unsigned int queryIntSetting(const string & name, unsigned int def);
+void overrideSetting(const string & name, const Strings & value);
+
void reloadSettings();