From 60cb7de336035768089cc764a3fd7e8867a8d298 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 27 Feb 2009 11:04:41 +0000 Subject: * Allow options from the Nix config file to be overriden from the command line (e.g. "--option build-use-chroot true"). --- src/libstore/globals.cc | 12 ++++++++++++ src/libstore/globals.hh | 2 ++ 2 files changed, 14 insertions(+) (limited to 'src/libstore') diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 296cc4ac80..907627b659 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -34,6 +34,9 @@ static bool settingsRead = false; static std::map settings; +/* Overriden settings. */ +std::map 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 b8e2bae66e..687247cc74 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(); -- cgit 1.4.1