14 /* The default location of the daemon socket, relative to nixStateDir.
15 The socket is in a directory to allow you to control access to the
16 build daemon by setting the mode/ownership of the directory
17 appropriately. (This wouldn't work on the socket itself since it
18 must be deleted and recreated on startup.) */
19 #define DEFAULT_SOCKET_PATH "/daemon-socket/socket"
30 buildVerbosity
= lvlError
;
38 printBuildTrace
= false;
39 multiplexedBuildOutput
= false;
40 reservedSize
= 8 * 1024 * 1024;
43 syncBeforeRegistering
= false;
44 useSubstitutes
= true;
46 impersonateLinux26
= false;
49 logCompression
= COMPRESSION_BZIP2
;
51 logCompression
= COMPRESSION_GZIP
;
56 checkRootReachability
= false;
57 gcKeepOutputs
= false;
58 gcKeepDerivations
= true;
59 autoOptimiseStore
= false;
60 envKeepDerivations
= false;
61 lockCPU
= getEnv("NIX_AFFINITY_HACK", "1") == "1";
66 void Settings::processEnvironment()
68 nixStore
= canonPath(getEnv("NIX_STORE_DIR", getEnv("NIX_STORE", NIX_STORE_DIR
)));
69 nixLogDir
= canonPath(getEnv("GUIX_LOG_DIRECTORY", NIX_LOG_DIR
));
70 nixStateDir
= canonPath(getEnv("GUIX_STATE_DIRECTORY", NIX_STATE_DIR
));
71 nixDBPath
= getEnv("GUIX_DATABASE_DIRECTORY", nixStateDir
+ "/db");
72 nixConfDir
= canonPath(getEnv("GUIX_CONFIGURATION_DIRECTORY", GUIX_CONFIGURATION_DIRECTORY
));
73 nixBinDir
= canonPath(getEnv("NIX_BIN_DIR", NIX_BIN_DIR
));
74 nixDaemonSocketFile
= canonPath(nixStateDir
+ DEFAULT_SOCKET_PATH
);
75 guixProgram
= canonPath(getEnv("GUIX", nixBinDir
+ "/guix"));
79 void Settings::set(const string
& name
, const string
& value
)
81 settings
[name
] = value
;
82 overrides
[name
] = value
;
86 string
Settings::get(const string
& name
, const string
& def
)
88 auto i
= settings
.find(name
);
89 if (i
== settings
.end()) return def
;
94 Strings
Settings::get(const string
& name
, const Strings
& def
)
96 auto i
= settings
.find(name
);
97 if (i
== settings
.end()) return def
;
98 return tokenizeString
<Strings
>(i
->second
);
102 bool Settings::get(const string
& name
, bool def
)
109 int Settings::get(const string
& name
, int def
)
117 void Settings::update()
119 _get(tryFallback
, "build-fallback");
120 _get(maxBuildJobs
, "build-max-jobs");
121 _get(buildCores
, "build-cores");
122 _get(thisSystem
, "system");
123 _get(multiplexedBuildOutput
, "multiplexed-build-output");
124 _get(maxSilentTime
, "build-max-silent-time");
125 _get(buildTimeout
, "build-timeout");
126 _get(reservedSize
, "gc-reserved-space");
127 _get(fsyncMetadata
, "fsync-metadata");
128 _get(useSQLiteWAL
, "use-sqlite-wal");
129 _get(syncBeforeRegistering
, "sync-before-registering");
130 _get(useSubstitutes
, "build-use-substitutes");
131 _get(buildUsersGroup
, "build-users-group");
132 _get(useChroot
, "build-use-chroot");
133 _get(impersonateLinux26
, "build-impersonate-linux-26");
134 _get(keepLog
, "build-keep-log");
135 // _get(logCompression, "build-log-compression");
136 _get(maxLogSize
, "build-max-log-size");
137 _get(cacheFailure
, "build-cache-failure");
138 _get(pollInterval
, "build-poll-interval");
139 _get(checkRootReachability
, "gc-check-reachability");
140 _get(gcKeepOutputs
, "gc-keep-outputs");
141 _get(gcKeepDerivations
, "gc-keep-derivations");
142 _get(autoOptimiseStore
, "auto-optimise-store");
143 _get(envKeepDerivations
, "env-keep-derivations");
147 void Settings::_get(string
& res
, const string
& name
)
149 SettingsMap::iterator i
= settings
.find(name
);
150 if (i
== settings
.end()) return;
155 void Settings::_get(bool & res
, const string
& name
)
157 SettingsMap::iterator i
= settings
.find(name
);
158 if (i
== settings
.end()) return;
159 if (i
->second
== "true") res
= true;
160 else if (i
->second
== "false") res
= false;
161 else throw Error(format("configuration option `%1%' should be either `true' or `false', not `%2%'")
166 void Settings::_get(StringSet
& res
, const string
& name
)
168 SettingsMap::iterator i
= settings
.find(name
);
169 if (i
== settings
.end()) return;
171 Strings ss
= tokenizeString
<Strings
>(i
->second
);
172 res
.insert(ss
.begin(), ss
.end());
175 void Settings::_get(Strings
& res
, const string
& name
)
177 SettingsMap::iterator i
= settings
.find(name
);
178 if (i
== settings
.end()) return;
179 res
= tokenizeString
<Strings
>(i
->second
);
183 template<class N
> void Settings::_get(N
& res
, const string
& name
)
185 SettingsMap::iterator i
= settings
.find(name
);
186 if (i
== settings
.end()) return;
187 if (!string2Int(i
->second
, res
))
188 throw Error(format("configuration setting `%1%' should have an integer value") % name
);
192 string
Settings::pack()
195 foreach (SettingsMap::iterator
, i
, settings
) {
196 if (i
->first
.find('\n') != string::npos
||
197 i
->first
.find('=') != string::npos
||
198 i
->second
.find('\n') != string::npos
)
199 throw Error("invalid option name/value");
200 s
+= i
->first
; s
+= '='; s
+= i
->second
; s
+= '\n';
206 Settings::SettingsMap
Settings::getOverrides()
212 const string nixVersion
= PACKAGE_VERSION
;