2012-07-18 21:59:03 +03:00
|
|
|
#pragma once
|
2003-06-16 16:33:38 +03:00
|
|
|
|
2006-09-05 00:06:23 +03:00
|
|
|
#include "types.hh"
|
2016-04-25 16:26:07 +03:00
|
|
|
#include "logging.hh"
|
2006-09-05 00:06:23 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
#include <map>
|
2012-09-25 20:00:19 +03:00
|
|
|
#include <sys/types.h>
|
2012-07-31 02:55:41 +03:00
|
|
|
|
2006-09-05 00:06:23 +03:00
|
|
|
|
|
|
|
namespace nix {
|
2003-06-16 16:33:38 +03:00
|
|
|
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
struct Settings {
|
|
|
|
|
2012-08-01 01:19:44 +03:00
|
|
|
typedef std::map<string, string> SettingsMap;
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
Settings();
|
|
|
|
|
|
|
|
void loadConfFile();
|
|
|
|
|
|
|
|
void set(const string & name, const string & value);
|
|
|
|
|
|
|
|
void update();
|
|
|
|
|
|
|
|
string pack();
|
|
|
|
|
2014-02-14 12:48:42 +02:00
|
|
|
void unpack(const string & pack);
|
2014-02-08 07:05:46 +02:00
|
|
|
|
2012-08-01 01:19:44 +03:00
|
|
|
SettingsMap getOverrides();
|
|
|
|
|
Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string
properties, which led to a proliferation of code all over the place making
up new options without any sort of central registry of valid options. This
commit pulls all those options back into the central Settings class and
removes the public get() methods, to discourage future abuses like that.
Furthermore, because we know the full set of options ahead of time, we
now fail loudly if someone enters an unrecognized option, thus preventing
subtle typos. With some template fun, we could probably also dump the full
set of options (with documentation, defaults, etc.) to the command line,
but I'm not doing that yet here.
2017-02-22 05:50:18 +02:00
|
|
|
/* TODO: the comments below should be strings and exposed via a nice command-line UI or similar.
|
|
|
|
We should probably replace it with some sort of magic template or macro to minimize the amount
|
|
|
|
of duplication and pain here. */
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* The directory where we store sources and derived files. */
|
|
|
|
Path nixStore;
|
|
|
|
|
|
|
|
Path nixDataDir; /* !!! fix */
|
|
|
|
|
2015-04-16 19:46:17 +03:00
|
|
|
Path nixPrefix;
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* The directory where we log various operations. */
|
|
|
|
Path nixLogDir;
|
|
|
|
|
|
|
|
/* The directory where state is stored. */
|
|
|
|
Path nixStateDir;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
|
2013-03-08 02:24:59 +02:00
|
|
|
/* File name of the socket the daemon listens to. */
|
|
|
|
Path nixDaemonSocketFile;
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* 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;
|
|
|
|
|
|
|
|
/* Whether, if we cannot realise the known closure corresponding
|
|
|
|
to a derivation, we should try to normalise the derivation
|
|
|
|
instead. */
|
|
|
|
bool tryFallback;
|
|
|
|
|
2016-04-25 17:47:46 +03:00
|
|
|
/* Whether to show build log output in real time. */
|
|
|
|
bool verboseBuild = true;
|
|
|
|
|
|
|
|
/* If verboseBuild is false, the number of lines of the tail of
|
|
|
|
the log to show if a build fails. */
|
|
|
|
size_t logLines = 10;
|
2003-06-16 16:33:38 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Maximum number of parallel build jobs. 0 means unlimited. */
|
|
|
|
unsigned int maxBuildJobs;
|
2003-06-16 16:33:38 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* 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;
|
2003-07-10 16:41:28 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Read-only mode. Don't copy stuff to the store, don't change
|
|
|
|
the database. */
|
|
|
|
bool readOnlyMode;
|
2003-06-16 16:33:38 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* The canonical system name, as returned by config.guess. */
|
|
|
|
string thisSystem;
|
2003-11-19 19:27:16 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* 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;
|
2003-07-31 16:47:13 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* The maximum duration in seconds that a builder can run. 0
|
|
|
|
means infinity. */
|
|
|
|
time_t buildTimeout;
|
2005-02-02 00:07:48 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to use build hooks (for distributed builds). Sometimes
|
|
|
|
users want to disable this from the command-line. */
|
|
|
|
bool useBuildHook;
|
2006-12-04 15:09:16 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Amount of reserved space for the garbage collector
|
|
|
|
(/nix/var/nix/db/reserved). */
|
|
|
|
off_t reservedSize;
|
2004-06-25 18:36:09 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether SQLite should use fsync. */
|
|
|
|
bool fsyncMetadata;
|
2004-06-28 13:42:57 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether SQLite should use WAL mode. */
|
|
|
|
bool useSQLiteWAL;
|
2004-01-13 18:35:43 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to call sync() before registering a path as valid. */
|
|
|
|
bool syncBeforeRegistering;
|
2004-05-12 17:20:32 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to use substitutes. */
|
|
|
|
bool useSubstitutes;
|
2010-06-23 17:34:08 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* The Unix group that contains the build users. */
|
|
|
|
string buildUsersGroup;
|
2004-10-25 17:38:23 +03:00
|
|
|
|
2014-02-08 07:05:46 +02:00
|
|
|
/* Set of ssh connection strings for the ssh substituter */
|
|
|
|
Strings sshSubstituterHosts;
|
|
|
|
|
2014-02-19 14:05:15 +02:00
|
|
|
/* Whether to use the ssh substituter at all */
|
|
|
|
bool useSshSubstituter;
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to impersonate a Linux 2.6 machine on newer kernels. */
|
|
|
|
bool impersonateLinux26;
|
2011-06-30 18:19:13 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to store build logs. */
|
|
|
|
bool keepLog;
|
2007-08-12 03:29:28 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to compress logs. */
|
|
|
|
bool compressLog;
|
2007-11-16 18:15:26 +02:00
|
|
|
|
2013-09-02 12:58:18 +03:00
|
|
|
/* Maximum number of bytes a builder can write to stdout/stderr
|
|
|
|
before being killed (0 means no limit). */
|
|
|
|
unsigned long maxLogSize;
|
|
|
|
|
2016-12-06 18:43:39 +02:00
|
|
|
/* When build-repeat > 0 and verboseBuild == true, whether to
|
|
|
|
print repeated builds (i.e. builds other than the first one) to
|
|
|
|
stderr. Hack to prevent Hydra logs from being polluted. */
|
|
|
|
bool printRepeatedBuilds = true;
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* How often (in seconds) to poll for locks. */
|
|
|
|
unsigned int pollInterval;
|
2008-11-12 13:08:27 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to check if new GC roots can in fact be found by the
|
|
|
|
garbage collector. */
|
|
|
|
bool checkRootReachability;
|
2008-11-12 13:08:27 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether the garbage collector should keep outputs of live
|
|
|
|
derivations. */
|
|
|
|
bool gcKeepOutputs;
|
2003-08-19 12:04:47 +03:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether the garbage collector should keep derivers of live
|
|
|
|
paths. */
|
|
|
|
bool gcKeepDerivations;
|
2005-02-02 00:07:48 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to automatically replace files with identical contents
|
|
|
|
with hard links. */
|
|
|
|
bool autoOptimiseStore;
|
2006-02-16 15:58:10 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
/* Whether to add derivations as a dependency of user environments
|
|
|
|
(to prevent them from being GCed). */
|
|
|
|
bool envKeepDerivations;
|
2005-02-14 15:07:09 +02:00
|
|
|
|
2013-09-06 17:36:56 +03:00
|
|
|
/* Whether to lock the Nix client and worker to the same CPU. */
|
|
|
|
bool lockCPU;
|
|
|
|
|
2013-11-12 13:51:59 +02:00
|
|
|
/* Whether to show a stack trace if Nix evaluation fails. */
|
|
|
|
bool showTrace;
|
|
|
|
|
2017-03-30 15:04:21 +03:00
|
|
|
/* Whether native-code enabling primops should be enabled */
|
|
|
|
bool enableNativeCode;
|
2014-06-24 17:50:03 +03:00
|
|
|
|
Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string
properties, which led to a proliferation of code all over the place making
up new options without any sort of central registry of valid options. This
commit pulls all those options back into the central Settings class and
removes the public get() methods, to discourage future abuses like that.
Furthermore, because we know the full set of options ahead of time, we
now fail loudly if someone enters an unrecognized option, thus preventing
subtle typos. With some template fun, we could probably also dump the full
set of options (with documentation, defaults, etc.) to the command line,
but I'm not doing that yet here.
2017-02-22 05:50:18 +02:00
|
|
|
/* Whether to enable sandboxed builds (string until we get an enum for true/false/relaxed) */
|
|
|
|
string useSandbox;
|
|
|
|
|
|
|
|
/* The basic set of paths to expose in a sandbox */
|
|
|
|
PathSet sandboxPaths;
|
|
|
|
|
|
|
|
/* Any extra sandbox paths to expose */
|
|
|
|
PathSet extraSandboxPaths;
|
|
|
|
|
|
|
|
/* Whether to allow certain questionable operations (like fetching) during evaluation */
|
|
|
|
bool restrictEval;
|
|
|
|
|
|
|
|
/* The number of times to repeat a build to check for determinism */
|
|
|
|
int buildRepeat;
|
|
|
|
|
|
|
|
/* Which prefixes to allow derivations to ask for access to (primarily for Darwin) */
|
|
|
|
PathSet allowedImpureHostPrefixes;
|
|
|
|
|
|
|
|
/* The size of /dev/shm in the build sandbox (for Linux) */
|
|
|
|
string sandboxShmSize;
|
|
|
|
|
|
|
|
/* Whether to log Darwin sandbox access violations to the system log */
|
|
|
|
bool darwinLogSandboxViolations;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
bool runDiffHook;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
string diffHook;
|
|
|
|
|
|
|
|
/* Whether to fail if repeated builds produce different output */
|
|
|
|
bool enforceDeterminism;
|
|
|
|
|
|
|
|
/* The known public keys for a binary cache */
|
|
|
|
Strings binaryCachePublicKeys;
|
|
|
|
|
|
|
|
/* Secret keys to use for build output signing */
|
|
|
|
Strings secretKeyFiles;
|
|
|
|
|
|
|
|
/* Number of parallel connections to hit a binary cache with when finding out if it contains hashes */
|
|
|
|
int binaryCachesParallelConnections;
|
|
|
|
|
|
|
|
/* Whether to enable HTTP2 */
|
|
|
|
bool enableHttp2;
|
|
|
|
|
|
|
|
/* How soon to expire tarballs like builtins.fetchTarball and (ugh, bad name) builtins.fetchurl */
|
|
|
|
int tarballTtl;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
string signedBinaryCaches;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
Strings substituters;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
Strings binaryCaches;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
Strings extraBinaryCaches;
|
|
|
|
|
|
|
|
/* Who we trust to ask the daemon to do unsafe things */
|
|
|
|
Strings trustedUsers;
|
|
|
|
|
|
|
|
/* ?Who we trust to use the daemon in safe ways */
|
|
|
|
Strings allowedUsers;
|
|
|
|
|
|
|
|
/* ??? */
|
|
|
|
bool printMissing;
|
|
|
|
|
2015-04-18 23:56:02 +03:00
|
|
|
/* The hook to run just before a build to set derivation-specific
|
|
|
|
build settings */
|
|
|
|
Path preBuildHook;
|
|
|
|
|
2017-02-16 15:46:36 +02:00
|
|
|
/* Path to the netrc file used to obtain usernames/passwords for
|
|
|
|
downloads. */
|
|
|
|
Path netrcFile;
|
|
|
|
|
2017-03-06 21:30:35 +02:00
|
|
|
/* Path to the SSL CA file used */
|
|
|
|
Path caFile;
|
|
|
|
|
2017-03-08 15:46:12 +02:00
|
|
|
/* Whether we allow import-from-derivation */
|
|
|
|
bool enableImportFromDerivation;
|
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
private:
|
Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string
properties, which led to a proliferation of code all over the place making
up new options without any sort of central registry of valid options. This
commit pulls all those options back into the central Settings class and
removes the public get() methods, to discourage future abuses like that.
Furthermore, because we know the full set of options ahead of time, we
now fail loudly if someone enters an unrecognized option, thus preventing
subtle typos. With some template fun, we could probably also dump the full
set of options (with documentation, defaults, etc.) to the command line,
but I'm not doing that yet here.
2017-02-22 05:50:18 +02:00
|
|
|
StringSet deprecatedOptions;
|
2012-08-01 01:19:44 +03:00
|
|
|
SettingsMap settings, overrides;
|
2009-02-27 13:04:41 +02:00
|
|
|
|
Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string
properties, which led to a proliferation of code all over the place making
up new options without any sort of central registry of valid options. This
commit pulls all those options back into the central Settings class and
removes the public get() methods, to discourage future abuses like that.
Furthermore, because we know the full set of options ahead of time, we
now fail loudly if someone enters an unrecognized option, thus preventing
subtle typos. With some template fun, we could probably also dump the full
set of options (with documentation, defaults, etc.) to the command line,
but I'm not doing that yet here.
2017-02-22 05:50:18 +02:00
|
|
|
void checkDeprecated(const string & name);
|
|
|
|
|
2014-08-04 19:02:29 +03:00
|
|
|
void _get(string & res, const string & name);
|
Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string
properties, which led to a proliferation of code all over the place making
up new options without any sort of central registry of valid options. This
commit pulls all those options back into the central Settings class and
removes the public get() methods, to discourage future abuses like that.
Furthermore, because we know the full set of options ahead of time, we
now fail loudly if someone enters an unrecognized option, thus preventing
subtle typos. With some template fun, we could probably also dump the full
set of options (with documentation, defaults, etc.) to the command line,
but I'm not doing that yet here.
2017-02-22 05:50:18 +02:00
|
|
|
void _get(string & res, const string & name1, const string & name2);
|
2014-08-04 19:02:29 +03:00
|
|
|
void _get(bool & res, const string & name);
|
|
|
|
void _get(StringSet & res, const string & name);
|
Explicitly model all settings and fail on unrecognized ones
Previously, the Settings class allowed other code to query for string
properties, which led to a proliferation of code all over the place making
up new options without any sort of central registry of valid options. This
commit pulls all those options back into the central Settings class and
removes the public get() methods, to discourage future abuses like that.
Furthermore, because we know the full set of options ahead of time, we
now fail loudly if someone enters an unrecognized option, thus preventing
subtle typos. With some template fun, we could probably also dump the full
set of options (with documentation, defaults, etc.) to the command line,
but I'm not doing that yet here.
2017-02-22 05:50:18 +02:00
|
|
|
void _get(StringSet & res, const string & name1, const string & name2);
|
2014-08-04 19:02:29 +03:00
|
|
|
void _get(Strings & res, const string & name);
|
|
|
|
template<class N> void _get(N & res, const string & name);
|
2012-07-31 02:55:41 +03:00
|
|
|
};
|
2008-11-20 14:25:11 +02:00
|
|
|
|
2011-11-22 19:28:41 +02:00
|
|
|
|
2012-07-31 02:55:41 +03:00
|
|
|
// FIXME: don't use a global variable.
|
|
|
|
extern Settings settings;
|
2012-07-30 23:09:54 +03:00
|
|
|
|
2011-11-22 19:28:41 +02:00
|
|
|
|
2012-11-27 14:29:55 +02:00
|
|
|
extern const string nixVersion;
|
|
|
|
|
|
|
|
|
2006-09-05 00:06:23 +03:00
|
|
|
}
|