about summary refs log tree commit diff
path: root/src/libstore/globals.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/globals.hh')
-rw-r--r--src/libstore/globals.hh221
1 files changed, 145 insertions, 76 deletions
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index 30acf59ef54f..5783d9bf37ba 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -2,120 +2,189 @@
 
 #include "types.hh"
 
+#include <map>
+
 
 namespace nix {
 
 
-/* Path names. */
+struct Settings {
+
+    Settings();
+
+    void processEnvironment();
+
+    void loadConfFile();
+
+    void set(const string & name, const string & value);
+
+    void update();
+
+    string pack();
+
+    /* The directory where we store sources and derived files. */
+    Path nixStore;
+
+    Path nixDataDir; /* !!! fix */
+
+    /* 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;
+
+    /* 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;
+
+    /* Verbosity level for build output. */
+    Verbosity buildVerbosity;
 
-/* nixStore is the directory where we generally store atomic and
-   derived files. */
-extern string nixStore;
+    /* Maximum number of parallel build jobs.  0 means unlimited. */
+    unsigned int maxBuildJobs;
 
-extern string nixDataDir; /* !!! fix */
+    /* 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;
 
-/* nixLogDir is the directory where we log various operations. */ 
-extern string nixLogDir;
+    /* Read-only mode.  Don't copy stuff to the store, don't change
+       the database. */
+    bool readOnlyMode;
 
-/* nixStateDir is the directory where state is stored. */
-extern string nixStateDir;
+    /* The canonical system name, as returned by config.guess. */
+    string thisSystem;
 
-/* nixDBPath is the path name of our Berkeley DB environment. */
-extern string nixDBPath;
+    /* 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;
 
-/* nixConfDir is the directory where configuration files are
-   stored. */
-extern string nixConfDir;
+    /* The maximum duration in seconds that a builder can run.  0
+       means infinity.  */
+    time_t buildTimeout;
 
-/* nixLibexecDir is the directory where internal helper programs are
-   stored. */
-extern string nixLibexecDir;
+    /* 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;
 
-/* nixBinDir is the directory where the main programs are stored. */
-extern string nixBinDir;
+    /* 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:
 
-/* Misc. global flags. */
+       @ build-started <drvpath> <outpath> <system> <logfile>
+       @ build-failed <drvpath> <outpath> <exitcode> <error text>
+       @ build-succeeded <drvpath> <outpath>
+       @ substituter-started <outpath> <substituter>
+       @ substituter-failed <outpath> <exitcode> <error text>
+       @ substituter-succeeded <outpath>
 
-/* Whether to keep temporary directories of failed builds. */
-extern bool keepFailed;
+       Best combined with --no-build-output, otherwise stderr might
+       conceivably contain lines in this format printed by the
+       builders. */
+    bool printBuildTrace;
 
-/* Whether to keep building subgoals when a sibling (another subgoal
-   of the same goal) fails. */
-extern bool keepGoing;
+    /* Amount of reserved space for the garbage collector
+       (/nix/var/nix/db/reserved). */
+    off_t reservedSize;
 
-/* Whether, if we cannot realise the known closure corresponding to a
-   derivation, we should try to normalise the derivation instead. */
-extern bool tryFallback;
+    /* Whether SQLite should use fsync. */
+    bool fsyncMetadata;
 
-/* Verbosity level for build output. */
-extern Verbosity buildVerbosity;
+    /* Whether SQLite should use WAL mode. */
+    bool useSQLiteWAL;
 
-/* Maximum number of parallel build jobs.  0 means unlimited. */
-extern unsigned int maxBuildJobs;
+    /* Whether to call sync() before registering a path as valid. */
+    bool syncBeforeRegistering;
 
-/* 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. */
-extern unsigned int buildCores;
+    /* Whether to use substitutes. */
+    bool useSubstitutes;
 
-/* Read-only mode.  Don't copy stuff to the store, don't change the
-   database. */
-extern bool readOnlyMode;
+    /* The Unix group that contains the build users. */
+    string buildUsersGroup;
 
-/* The canonical system name, as returned by config.guess. */ 
-extern string thisSystem;
+    /* Whether to build in chroot. */
+    bool useChroot;
 
-/* The maximum time in seconds that a builer can go without producing
-   any output on stdout/stderr before it is killed.  0 means
-   infinity. */
-extern time_t maxSilentTime;
+    /* The directories from the host filesystem to be included in the
+       chroot. */
+    PathSet dirsInChroot;
 
-/* The maximum duration in seconds that a builder can run.  0 means
-   infinity.  */
-extern time_t buildTimeout;
+    /* Whether to impersonate a Linux 2.6 machine on newer kernels. */
+    bool impersonateLinux26;
 
-/* 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. */
-extern Paths substituters;
+    /* Whether to store build logs. */
+    bool keepLog;
 
-/* Whether to use build hooks (for distributed builds).  Sometimes
-   users want to disable this from the command-line. */
-extern bool useBuildHook;
+    /* Whether to compress logs. */
+    bool compressLog;
 
-/* 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:
+    /* Whether to cache build failures. */
+    bool cacheFailure;
 
-   @ build-started <drvpath> <outpath> <system> <logfile>
-   @ build-failed <drvpath> <outpath> <exitcode> <error text>
-   @ build-succeeded <drvpath> <outpath>
-   @ substituter-started <outpath> <substituter>
-   @ substituter-failed <outpath> <exitcode> <error text>
-   @ substituter-succeeded <outpath>
+    /* How often (in seconds) to poll for locks. */
+    unsigned int pollInterval;
 
-   Best combined with --no-build-output, otherwise stderr might
-   conceivably contain lines in this format printed by the builders.
-*/
-extern bool printBuildTrace;
+    /* 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;
 
-Strings querySetting(const string & name, const Strings & def);
+    /* Whether the garbage collector should keep derivers of live
+       paths. */
+    bool gcKeepDerivations;
 
-string querySetting(const string & name, const string & def);
+    /* Whether to automatically replace files with identical contents
+       with hard links. */
+    bool autoOptimiseStore;
 
-bool queryBoolSetting(const string & name, bool def);
+    /* Whether to add derivations as a dependency of user environments
+       (to prevent them from being GCed). */
+    bool envKeepDerivations;
 
-unsigned int queryIntSetting(const string & name, unsigned int def);
+private:
+    typedef std::map<string, string> SettingsMap;
 
-void overrideSetting(const string & name, const Strings & value);
+    SettingsMap settings;
 
-void reloadSettings();
+    void get(string & res, const string & name);
+    void get(bool & res, const string & name);
+    void get(PathSet & res, const string & name);
+    template<class N> void get(N & res, const string & name);
+};
 
-void setDefaultsFromEnvironment();
 
-string packSettings();
+// FIXME: don't use a global variable.
+extern Settings settings;
 
 
 }