aboutsummaryrefslogtreecommitdiff
path: root/nix/libstore/globals.hh
blob: b073f724b6751d25cd63f1dca5008e7866fc7aae (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
#pragma once

#include "config.h"
#include "types.hh"

#include <map>
#include <sys/types.h>


namespace nix {

enum CompressionType
{
    COMPRESSION_NONE = 0,
    COMPRESSION_GZIP = 1
#if HAVE_BZLIB_H
    , COMPRESSION_BZIP2 = 2
#endif
};

struct Settings {

    typedef std::map<string, string> SettingsMap;

    Settings();

    void processEnvironment();

    void set(const string & name, const string & value);

    string get(const string & name, const string & def);

    Strings get(const string & name, const Strings & def);

    bool get(const string & name, bool def);

    int get(const string & name, int def);

    void update();

    string pack();

    SettingsMap getOverrides();

    /* The directory where we store sources and derived files. */
    Path nixStore;

    /* The directory where we log various operations. */
    Path nixLogDir;

    /* The directory where state is stored. */
    Path nixStateDir;

    /* The directory where we keep the SQLite database. */
    Path nixDBPath;

    /* The directory where configuration files are stored. */
    Path nixConfDir;

    /* The directory where internal helper programs are stored. */
    Path nixLibexecDir;

    /* The directory where the main programs are stored. */
    Path nixBinDir;

    /* File name of the socket the daemon listens to.  */
    Path nixDaemonSocketFile;

    /* Whether to keep temporary directories of failed builds. */
    bool keepFailed;

    /* Whether to keep building subgoals when a sibling (another
       subgoal of the same goal) fails. */
    bool keepGoing;

    /* User and groud id of the client issuing the build request.  Used to set
       the owner and group of the kept temporary directories of failed
       builds. */
    uid_t clientUid;
    gid_t clientGid;

    /* Whether, if we cannot realise the known closure corresponding
       to a derivation, we should try to normalise the derivation
       instead. */
    bool tryFallback;

    /* Verbosity level for build output. */
    Verbosity buildVerbosity;

    /* Maximum number of parallel build jobs.  0 means unlimited. */
    unsigned int maxBuildJobs;

    /* Number of CPU cores to utilize in parallel within a build,
       i.e. by passing this number to Make via '-j'. 0 means that the
       number of actual CPU cores on the local host ought to be
       auto-detected. */
    unsigned int buildCores;

    /* Read-only mode.  Don't copy stuff to the store, don't change
       the database. */
    bool readOnlyMode;

    /* The canonical system name, as returned by config.guess. */
    string thisSystem;

    /* The maximum time in seconds that a builer can go without
       producing any output on stdout/stderr before it is killed.  0
       means infinity. */
    time_t maxSilentTime;

    /* The maximum duration in seconds that a builder can run.  0
       means infinity.  */
    time_t buildTimeout;

    /* The substituters.  There are programs that can somehow realise
       a store path without building, e.g., by downloading it or
       copying it from a CD. */
    Paths substituters;

    /* Whether to use build hooks (for distributed builds).  Sometimes
       users want to disable this from the command-line. */
    bool useBuildHook;

    /* Whether buildDerivations() should print out lines on stderr in
       a fixed format to allow its progress to be monitored.  Each
       line starts with a "@".  The following are defined:

       @ build-started <drvpath> <outpath> <system> <logfile> <pid>
       @ build-failed <drvpath> <outpath> <exitcode> <error text>
       @ build-succeeded <drvpath> <outpath>
       @ substituter-started <outpath> <substituter>
       @ substituter-failed <outpath> <exitcode> <error text>
       @ substituter-succeeded <outpath>

       Best combined with --no-build-output, otherwise stderr might
       conceivably contain lines in this format printed by the
       builders. */
    bool printBuildTrace;

    /* When true, 'buildDerivations' prefixes lines coming from builders so
       that clients know exactly which line comes from which builder, and
       which line comes from the daemon itself.  The prefix for data coming
       from builders is "log:PID:LEN:DATA" where PID uniquely identifies the
       builder (PID is given in "build-started" traces.)  */
    bool multiplexedBuildOutput;

    /* Amount of reserved space for the garbage collector
       (/nix/var/nix/db/reserved). */
    off_t reservedSize;

    /* Whether SQLite should use fsync. */
    bool fsyncMetadata;

    /* Whether SQLite should use WAL mode. */
    bool useSQLiteWAL;

    /* Whether to call sync() before registering a path as valid. */
    bool syncBeforeRegistering;

    /* Whether to use substitutes. */
    bool useSubstitutes;

    /* The Unix group that contains the build users. */
    string buildUsersGroup;

    /* Whether to build in chroot. */
    bool useChroot;

    /* Whether to impersonate a Linux 2.6 machine on newer kernels. */
    bool impersonateLinux26;

    /* Whether to store build logs. */
    bool keepLog;

    /* Whether to compress logs. */
    enum CompressionType logCompression;

    /* Maximum number of bytes a builder can write to stdout/stderr
       before being killed (0 means no limit). */
    unsigned long maxLogSize;

    /* Whether to cache build failures. */
    bool cacheFailure;

    /* How often (in seconds) to poll for locks. */
    unsigned int pollInterval;

    /* Whether to check if new GC roots can in fact be found by the
       garbage collector. */
    bool checkRootReachability;

    /* Whether the garbage collector should keep outputs of live
       derivations. */
    bool gcKeepOutputs;

    /* Whether the garbage collector should keep derivers of live
       paths. */
    bool gcKeepDerivations;

    /* Whether to automatically replace files with identical contents
       with hard links. */
    bool autoOptimiseStore;

    /* Whether to add derivations as a dependency of user environments
       (to prevent them from being GCed). */
    bool envKeepDerivations;

    /* Whether to lock the Nix client and worker to the same CPU. */
    bool lockCPU;

    /* Whether to show a stack trace if Nix evaluation fails. */
    bool showTrace;

private:
    SettingsMap settings, overrides;

    void _get(string & res, const string & name);
    void _get(bool & res, const string & name);
    void _get(StringSet & res, const string & name);
    void _get(Strings & res, const string & name);
    template<class N> void _get(N & res, const string & name);
};


// FIXME: don't use a global variable.
extern Settings settings;


extern const string nixVersion;


}
...* gnu/system/image.scm: Remove a left-over since maybe-with-target procedure was removed. Mathieu Othacehe 2020-06-13image: Remove 'maybe-with-target'....* gnu/system/image.scm (maybe-with-target): Remove, (system-image): adapt accordingly. Mathieu Othacehe 2020-06-13image: Add 'target' support....* gnu/image.scm (<image>)[target]: New field, (image-target): new public method. * gnu/system/image.scm (hurd-disk-image): Set "i586-pc-gnu" as image 'target' field, (maybe-with-target): new procedure, (system-image): honor image 'target' field using the above procedure. Mathieu Othacehe 2020-06-13image: Make 'find-image' non-monadic....* gnu/system/image.scm (find-image): Make non-monadic. Add 'target' parameter. * gnu/tests/install.scm (run-install): Update caller, passing (%current-target-system). * guix/scripts/system.scm (perform-action): Likewise. Jan (janneke) Nieuwenhuizen 2020-06-12system: image: Do not produce an HFS tree when building an ISO....Use "mbr_only" mode to make sure that no HFS+ tree are generated. * gnu/system/image.scm (system-image): Set MKRESCUE_SED_MODE to "mbr_only". Mathieu Othacehe 2020-06-08hurd-boot: Further cleanup of "rc"....* gnu/packages/hurd.scm (hurd-rc-script): Move implementation to ... * gnu/build/hurd-boot.scm (boot-hurd-system): ...here, new file. * gnu/build/linux-boot.scm (make-hurd-device-nodes): Move there likewise. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. Jan (janneke) Nieuwenhuizen 2020-06-08image: Add Hurd support....* gnu/system/image.scm (hurd-disk-image): New exported variable, (root-offset, root-label): new variables, (esp-partition, root-partition): adapt accordingly, (find-image): add Hurd support. Mathieu Othacehe 2020-05-29image: Do not use VM to create disk-images....Now that installing Grub on raw disk-images is supported, we do not need to rely on (gnu system vm) module. * gnu/system/image.scm (make-system-image): Rename to ... (system-image): ... this, and remove the compatibility wrapper. (find-image): Turn to a monadic procedure. This will become useful when introducing Hurd support, to be able to detect the target system. * gnu/ci.scm (qemu-jobs): Use lower-object now that system-image returns a file-like object. * gnu/tests/install.scm (run-install): Ditto. * guix/scripts/system.scm (system-derivation-for-action): Add a 'base-image' argument, (perform-action): adapt accordingly. Mathieu Othacehe 2020-05-29image: Add a post-MBR gap to the default image....The generic 'efi-disk-image' needs to be bootable on systems without EFI. To do that, GRUB is installed in the post-MBR gap. Make sure that the first partition starts with an offset, to make this gap large enough for GRUB. * gnu/system/image.scm (root-offset, root-label): New variables, (esp-partition): use 'root-offset' as the partition offset, (root-partition): use 'root-label' as the partition label. Mathieu Othacehe 2020-05-29system: image: Fix image-with-os....* gnu/system/image.scm (image-with-os): Do not reorder partitions, as we want them to be created according to definition order. Mathieu Othacehe 2020-05-29image: Use grub-efi to install the EFI bootloader....* gnu/build/image.scm (initialize-efi-partition): Rename bootloader-package argument to grub-efi. * gnu/system/image.scm (system-disk-image): Adapt accordingly to pass grub-efi package. Mathieu Othacehe 2020-05-29system: image: Correct genimage configuration file indentation....* gnu/system/image.scm (system-disk-image): Fix genimage configuration file indentation. Mathieu Othacehe 2020-05-29image: Add bootloader installation support....* gnu/build/image.scm (initialize-root-partition): Add bootloader-package and bootloader-installer arguments. Run the bootloader-installer if defined. * gnu/system/image.scm (system-disk-image): Adapt the partition initializer call accordingly. Mathieu Othacehe 2020-05-29bootloader: Add 'disk-image-installer'....* gnu/bootloader.scm (<bootloader>)[disk-image-installer]: New field, (bootloader-disk-image-installer): export it. * gnu/bootloader/grub.scm (install-grub-disk-image): New procedure ... (grub-bootloader): ... used as "disk-image-installer" here. (grub-efi-bootloader): set "disk-image-installer" to #f. * gnu/system/image.scm (root-partition?, find-root-partition): Move to "Helpers" section. (root-partition-index): New procedure. (system-disk-image): Honor disk-image-installer, and use it to install the bootloader directly on the disk-image, if supported. Mathieu Othacehe 2020-05-26image: Add partition file-system options support....* gnu/image.scm (<partition>)[file-system-options]: New field, (partition-file-system-options): new exported procedure. * gnu/system/image.scm (partition->gexp): Adapt accordingly. * gnu/build/image.scm (sexp->partition): Also adapt accordingly, (make-ext-image): and pass file-system options to mke2fs. Mathieu Othacehe 2020-05-26image: Set offset default to zero....* gnu/image.scm (<partition>)[offset]: Set to zero by default. * gnu/system/image.scm (system-disk-image): Adapt accordingly. Mathieu Othacehe 2020-05-26system: image: Fix disk-image cross-compilation....* gnu/system/image.scm (system-disk-image): Use the native version of the helper packages (e2fsprogs, dosfstools, mtools, genimage, coreutils and findutils). Mathieu Othacehe 2020-05-26image: Add partition offset support....* gnu/image.scm (partition-offset): New procedure, (<partition>)[offset]: new field. * gnu/system/image.scm (system-disk-image): Apply the partition offset. Mathieu Othacehe 2020-05-05image: Add a new API....Raw disk-images and ISO9660 images are created in a Qemu virtual machine. This is quite fragile, very slow, and almost unusable without KVM. For all these reasons, add support for host image generation. This implies the use new image generation mechanisms. - Raw disk images: images of partitions are created using tools such as mke2fs and mkdosfs depending on the partition file-system type. The partition images are then assembled into a final image using genimage. - ISO9660 images: the ISO root directory is populated within the store. GNU xorriso is then called on that directory, in the exact same way as this is done in (gnu build vm) module. Those mechanisms are built upon the new (gnu image) module. * gnu/image.scm: New file. * gnu/system/image.scm: New file. * gnu/build/image: New file. * gnu/local.mk: Add them. * gnu/system/vm.scm (system-disk-image): Rename to system-disk-image-in-vm. * gnu/ci.scm (qemu-jobs): Adapt to new API. * gnu/tests/install.scm (run-install): Ditto. * guix/scripts/system.scm (system-derivation-for-action): Ditto. Mathieu Othacehe