about summary refs log tree commit diff
path: root/src/libstore/globals.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-30T20·09-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-07-30T20·09-0400
commitd059bf48e4bd4d1f50593dbe60953de8b2d395c7 (patch)
tree4dd8fed0eb5c2827000c84fd77719e4454adb627 /src/libstore/globals.cc
parentf9613da18033d0a9835bc57ac2142aca754983cf (diff)
Pass configuration settings to the substituters
Previously substituters could read nix.conf themselves, but this
didn't take --option flags into account.
Diffstat (limited to 'src/libstore/globals.cc')
-rw-r--r--src/libstore/globals.cc23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc
index 9636bf49d987..a28e08427da5 100644
--- a/src/libstore/globals.cc
+++ b/src/libstore/globals.cc
@@ -36,10 +36,12 @@ bool printBuildTrace = false;
 
 static bool settingsRead = false;
 
-static std::map<string, Strings> settings;
+typedef std::map<string, Strings> Settings;
+
+static Settings settings;
 
 /* Overriden settings. */
-std::map<string, Strings> settingsCmdline;
+Settings settingsCmdline;
 
 
 string & at(Strings & ss, unsigned int n)
@@ -82,7 +84,7 @@ static void readSettings()
     };
 
     settings.insert(settingsCmdline.begin(), settingsCmdline.end());
-    
+
     settingsRead = true;
 }
 
@@ -90,7 +92,7 @@ static void readSettings()
 Strings querySetting(const string & name, const Strings & def)
 {
     if (!settingsRead) readSettings();
-    std::map<string, Strings>::iterator i = settings.find(name);
+    Settings::iterator i = settings.find(name);
     return i == settings.end() ? def : i->second;
 }
 
@@ -169,5 +171,16 @@ void setDefaultsFromEnvironment()
     buildTimeout = queryIntSetting("build-timeout", 0);
 }
 
- 
+
+string packSettings()
+{
+    string s;
+    if (!settingsRead) readSettings();
+    foreach (Settings::iterator, i, settings) {
+        s += i->first; s += '='; s += concatStringsSep(" ", i->second); s += '\n';
+    }
+    return s;
+}
+
+
 }