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