gnu: subversion: Don't create 'perllocal.pod'.
[jackhill/guix/guix.git] / nix / libstore / globals.hh
1 #pragma once
2
3 #include "types.hh"
4
5 #include <map>
6 #include <sys/types.h>
7
8
9 namespace nix {
10
11
12 struct Settings {
13
14 typedef std::map<string, string> SettingsMap;
15
16 Settings();
17
18 void processEnvironment();
19
20 void loadConfFile();
21
22 void set(const string & name, const string & value);
23
24 string get(const string & name, const string & def);
25
26 Strings get(const string & name, const Strings & def);
27
28 bool get(const string & name, bool def);
29
30 int get(const string & name, int def);
31
32 void update();
33
34 string pack();
35
36 void unpack(const string & pack);
37
38 SettingsMap getOverrides();
39
40 /* The directory where we store sources and derived files. */
41 Path nixStore;
42
43 Path nixDataDir; /* !!! fix */
44
45 /* The directory where we log various operations. */
46 Path nixLogDir;
47
48 /* The directory where state is stored. */
49 Path nixStateDir;
50
51 /* The directory where we keep the SQLite database. */
52 Path nixDBPath;
53
54 /* The directory where configuration files are stored. */
55 Path nixConfDir;
56
57 /* The directory where internal helper programs are stored. */
58 Path nixLibexecDir;
59
60 /* The directory where the main programs are stored. */
61 Path nixBinDir;
62
63 /* File name of the socket the daemon listens to. */
64 Path nixDaemonSocketFile;
65
66 /* Whether to keep temporary directories of failed builds. */
67 bool keepFailed;
68
69 /* Whether to keep building subgoals when a sibling (another
70 subgoal of the same goal) fails. */
71 bool keepGoing;
72
73 /* User and groud id of the client issuing the build request. Used to set
74 the owner and group of the kept temporary directories of failed
75 builds. */
76 uid_t clientUid;
77 gid_t clientGid;
78
79 /* Whether, if we cannot realise the known closure corresponding
80 to a derivation, we should try to normalise the derivation
81 instead. */
82 bool tryFallback;
83
84 /* Verbosity level for build output. */
85 Verbosity buildVerbosity;
86
87 /* Maximum number of parallel build jobs. 0 means unlimited. */
88 unsigned int maxBuildJobs;
89
90 /* Number of CPU cores to utilize in parallel within a build,
91 i.e. by passing this number to Make via '-j'. 0 means that the
92 number of actual CPU cores on the local host ought to be
93 auto-detected. */
94 unsigned int buildCores;
95
96 /* Read-only mode. Don't copy stuff to the store, don't change
97 the database. */
98 bool readOnlyMode;
99
100 /* The canonical system name, as returned by config.guess. */
101 string thisSystem;
102
103 /* The maximum time in seconds that a builer can go without
104 producing any output on stdout/stderr before it is killed. 0
105 means infinity. */
106 time_t maxSilentTime;
107
108 /* The maximum duration in seconds that a builder can run. 0
109 means infinity. */
110 time_t buildTimeout;
111
112 /* The substituters. There are programs that can somehow realise
113 a store path without building, e.g., by downloading it or
114 copying it from a CD. */
115 Paths substituters;
116
117 /* Whether to use build hooks (for distributed builds). Sometimes
118 users want to disable this from the command-line. */
119 bool useBuildHook;
120
121 /* Whether buildDerivations() should print out lines on stderr in
122 a fixed format to allow its progress to be monitored. Each
123 line starts with a "@". The following are defined:
124
125 @ build-started <drvpath> <outpath> <system> <logfile>
126 @ build-failed <drvpath> <outpath> <exitcode> <error text>
127 @ build-succeeded <drvpath> <outpath>
128 @ substituter-started <outpath> <substituter>
129 @ substituter-failed <outpath> <exitcode> <error text>
130 @ substituter-succeeded <outpath>
131
132 Best combined with --no-build-output, otherwise stderr might
133 conceivably contain lines in this format printed by the
134 builders. */
135 bool printBuildTrace;
136
137 /* Amount of reserved space for the garbage collector
138 (/nix/var/nix/db/reserved). */
139 off_t reservedSize;
140
141 /* Whether SQLite should use fsync. */
142 bool fsyncMetadata;
143
144 /* Whether SQLite should use WAL mode. */
145 bool useSQLiteWAL;
146
147 /* Whether to call sync() before registering a path as valid. */
148 bool syncBeforeRegistering;
149
150 /* Whether to use substitutes. */
151 bool useSubstitutes;
152
153 /* The Unix group that contains the build users. */
154 string buildUsersGroup;
155
156 /* Whether to build in chroot. */
157 bool useChroot;
158
159 /* Set of ssh connection strings for the ssh substituter */
160 Strings sshSubstituterHosts;
161
162 /* Whether to use the ssh substituter at all */
163 bool useSshSubstituter;
164
165 /* Whether to impersonate a Linux 2.6 machine on newer kernels. */
166 bool impersonateLinux26;
167
168 /* Whether to store build logs. */
169 bool keepLog;
170
171 /* Whether to compress logs. */
172 bool compressLog;
173
174 /* Maximum number of bytes a builder can write to stdout/stderr
175 before being killed (0 means no limit). */
176 unsigned long maxLogSize;
177
178 /* Whether to cache build failures. */
179 bool cacheFailure;
180
181 /* How often (in seconds) to poll for locks. */
182 unsigned int pollInterval;
183
184 /* Whether to check if new GC roots can in fact be found by the
185 garbage collector. */
186 bool checkRootReachability;
187
188 /* Whether the garbage collector should keep outputs of live
189 derivations. */
190 bool gcKeepOutputs;
191
192 /* Whether the garbage collector should keep derivers of live
193 paths. */
194 bool gcKeepDerivations;
195
196 /* Whether to automatically replace files with identical contents
197 with hard links. */
198 bool autoOptimiseStore;
199
200 /* Whether to add derivations as a dependency of user environments
201 (to prevent them from being GCed). */
202 bool envKeepDerivations;
203
204 /* Whether to lock the Nix client and worker to the same CPU. */
205 bool lockCPU;
206
207 /* Whether to show a stack trace if Nix evaluation fails. */
208 bool showTrace;
209
210 /* A list of URL prefixes that can return Nix build logs. */
211 Strings logServers;
212
213 /* Whether the importNative primop should be enabled */
214 bool enableImportNative;
215
216 private:
217 SettingsMap settings, overrides;
218
219 void _get(string & res, const string & name);
220 void _get(bool & res, const string & name);
221 void _get(StringSet & res, const string & name);
222 void _get(Strings & res, const string & name);
223 template<class N> void _get(N & res, const string & name);
224 };
225
226
227 // FIXME: don't use a global variable.
228 extern Settings settings;
229
230
231 extern const string nixVersion;
232
233
234 }