gnu: linux-libre: Update to 5.1.4.
[guix.git] / nix / libstore / globals.hh
blobb073f724b6751d25cd63f1dca5008e7866fc7aae
1 #pragma once
3 #include "config.h"
4 #include "types.hh"
6 #include <map>
7 #include <sys/types.h>
10 namespace nix {
12 enum CompressionType
14 COMPRESSION_NONE = 0,
15 COMPRESSION_GZIP = 1
16 #if HAVE_BZLIB_H
17 , COMPRESSION_BZIP2 = 2
18 #endif
21 struct Settings {
23 typedef std::map<string, string> SettingsMap;
25 Settings();
27 void processEnvironment();
29 void set(const string & name, const string & value);
31 string get(const string & name, const string & def);
33 Strings get(const string & name, const Strings & def);
35 bool get(const string & name, bool def);
37 int get(const string & name, int def);
39 void update();
41 string pack();
43 SettingsMap getOverrides();
45 /* The directory where we store sources and derived files. */
46 Path nixStore;
48 /* The directory where we log various operations. */
49 Path nixLogDir;
51 /* The directory where state is stored. */
52 Path nixStateDir;
54 /* The directory where we keep the SQLite database. */
55 Path nixDBPath;
57 /* The directory where configuration files are stored. */
58 Path nixConfDir;
60 /* The directory where internal helper programs are stored. */
61 Path nixLibexecDir;
63 /* The directory where the main programs are stored. */
64 Path nixBinDir;
66 /* File name of the socket the daemon listens to. */
67 Path nixDaemonSocketFile;
69 /* Whether to keep temporary directories of failed builds. */
70 bool keepFailed;
72 /* Whether to keep building subgoals when a sibling (another
73 subgoal of the same goal) fails. */
74 bool keepGoing;
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;
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;
87 /* Verbosity level for build output. */
88 Verbosity buildVerbosity;
90 /* Maximum number of parallel build jobs. 0 means unlimited. */
91 unsigned int maxBuildJobs;
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;
99 /* Read-only mode. Don't copy stuff to the store, don't change
100 the database. */
101 bool readOnlyMode;
103 /* The canonical system name, as returned by config.guess. */
104 string thisSystem;
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;
111 /* The maximum duration in seconds that a builder can run. 0
112 means infinity. */
113 time_t buildTimeout;
115 /* The substituters. There are programs that can somehow realise
116 a store path without building, e.g., by downloading it or
117 copying it from a CD. */
118 Paths substituters;
120 /* Whether to use build hooks (for distributed builds). Sometimes
121 users want to disable this from the command-line. */
122 bool useBuildHook;
124 /* Whether buildDerivations() should print out lines on stderr in
125 a fixed format to allow its progress to be monitored. Each
126 line starts with a "@". The following are defined:
128 @ build-started <drvpath> <outpath> <system> <logfile> <pid>
129 @ build-failed <drvpath> <outpath> <exitcode> <error text>
130 @ build-succeeded <drvpath> <outpath>
131 @ substituter-started <outpath> <substituter>
132 @ substituter-failed <outpath> <exitcode> <error text>
133 @ substituter-succeeded <outpath>
135 Best combined with --no-build-output, otherwise stderr might
136 conceivably contain lines in this format printed by the
137 builders. */
138 bool printBuildTrace;
140 /* When true, 'buildDerivations' prefixes lines coming from builders so
141 that clients know exactly which line comes from which builder, and
142 which line comes from the daemon itself. The prefix for data coming
143 from builders is "log:PID:LEN:DATA" where PID uniquely identifies the
144 builder (PID is given in "build-started" traces.) */
145 bool multiplexedBuildOutput;
147 /* Amount of reserved space for the garbage collector
148 (/nix/var/nix/db/reserved). */
149 off_t reservedSize;
151 /* Whether SQLite should use fsync. */
152 bool fsyncMetadata;
154 /* Whether SQLite should use WAL mode. */
155 bool useSQLiteWAL;
157 /* Whether to call sync() before registering a path as valid. */
158 bool syncBeforeRegistering;
160 /* Whether to use substitutes. */
161 bool useSubstitutes;
163 /* The Unix group that contains the build users. */
164 string buildUsersGroup;
166 /* Whether to build in chroot. */
167 bool useChroot;
169 /* Whether to impersonate a Linux 2.6 machine on newer kernels. */
170 bool impersonateLinux26;
172 /* Whether to store build logs. */
173 bool keepLog;
175 /* Whether to compress logs. */
176 enum CompressionType logCompression;
178 /* Maximum number of bytes a builder can write to stdout/stderr
179 before being killed (0 means no limit). */
180 unsigned long maxLogSize;
182 /* Whether to cache build failures. */
183 bool cacheFailure;
185 /* How often (in seconds) to poll for locks. */
186 unsigned int pollInterval;
188 /* Whether to check if new GC roots can in fact be found by the
189 garbage collector. */
190 bool checkRootReachability;
192 /* Whether the garbage collector should keep outputs of live
193 derivations. */
194 bool gcKeepOutputs;
196 /* Whether the garbage collector should keep derivers of live
197 paths. */
198 bool gcKeepDerivations;
200 /* Whether to automatically replace files with identical contents
201 with hard links. */
202 bool autoOptimiseStore;
204 /* Whether to add derivations as a dependency of user environments
205 (to prevent them from being GCed). */
206 bool envKeepDerivations;
208 /* Whether to lock the Nix client and worker to the same CPU. */
209 bool lockCPU;
211 /* Whether to show a stack trace if Nix evaluation fails. */
212 bool showTrace;
214 private:
215 SettingsMap settings, overrides;
217 void _get(string & res, const string & name);
218 void _get(bool & res, const string & name);
219 void _get(StringSet & res, const string & name);
220 void _get(Strings & res, const string & name);
221 template<class N> void _get(N & res, const string & name);
225 // FIXME: don't use a global variable.
226 extern Settings settings;
229 extern const string nixVersion;