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