From d51aede4afeb49182879f257b56394b70938028f Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Thu, 6 Jul 2006 15:30:37 +0000 Subject: [PATCH] * Allow the canonical system name to be specified at runtime in the Nix config file. --- nix.conf.example | 20 ++++++++++++++++++++ src/libmain/shared.cc | 2 ++ src/libstore/globals.cc | 3 ++- src/libstore/globals.hh | 3 +++ src/libutil/util.cc | 3 --- src/libutil/util.hh | 4 ---- 6 files changed, 27 insertions(+), 8 deletions(-) diff --git a/nix.conf.example b/nix.conf.example index 97c6f4b15..13b4cfa3d 100644 --- a/nix.conf.example +++ b/nix.conf.example @@ -97,3 +97,23 @@ # Example: # build-users = nix-builder-1 nix-builder-2 nix-builder-3 #build-users = + + +### Option `system' +# +# This option specifies the canonical Nix system name of the current +# installation, such as `i686-linux' or `powerpc-darwin'. Nix can +# only build derivations whose `system' attribute equals the value +# specified here. In general, it never makes sense to modify this +# value from its default, since you can use it to `lie' about the +# platform you are building on (e.g., perform a Mac OS build on a +# Linux machine; the result would obviously be wrong). It only makes +# sense if the Nix binaries can run on multiple platforms, e.g., +# `universal binaries' that run on `powerpc-darwin' and `i686-darwin'. +# +# It defaults to the canonical Nix system name detected by `configure' +# at build time. +# +# Example: +# system = i686-darwin +#system = diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc index 97528f123..fb24e8329 100644 --- a/src/libmain/shared.cc +++ b/src/libmain/shared.cc @@ -93,6 +93,8 @@ static void initAndRun(int argc, char * * argv) nixDBPath = getEnv("NIX_DB_DIR", nixStateDir + "/db"); nixConfDir = canonPath(getEnv("NIX_CONF_DIR", NIX_CONF_DIR)); + thisSystem = querySetting("system", SYSTEM); + /* Catch SIGINT. */ struct sigaction act, oact; act.sa_handler = sigintHandler; diff --git a/src/libstore/globals.cc b/src/libstore/globals.cc index 194e1165f..ac8e19b7d 100644 --- a/src/libstore/globals.cc +++ b/src/libstore/globals.cc @@ -17,6 +17,7 @@ bool tryFallback = false; Verbosity buildVerbosity = lvlInfo; unsigned int maxBuildJobs = 1; bool readOnlyMode = false; +string thisSystem = "unset"; static bool settingsRead = false; @@ -26,7 +27,7 @@ static map settings; string & at(Strings & ss, unsigned int n) { - Strings::iterator i =ss.begin(); + Strings::iterator i = ss.begin(); advance(i, n); return *i; } diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh index b5de709f7..408076b75 100644 --- a/src/libstore/globals.hh +++ b/src/libstore/globals.hh @@ -53,6 +53,9 @@ extern unsigned int maxBuildJobs; database. */ extern bool readOnlyMode; +/* The canonical system name, as returned by config.guess. */ +extern string thisSystem; + Strings querySetting(const string & name, const Strings & def); diff --git a/src/libutil/util.cc b/src/libutil/util.cc index 973443cf1..9e3e0bae2 100644 --- a/src/libutil/util.cc +++ b/src/libutil/util.cc @@ -16,9 +16,6 @@ #include "util.hh" -string thisSystem = SYSTEM; - - Error::Error(const format & f) { err = f.str(); diff --git a/src/libutil/util.hh b/src/libutil/util.hh index 05cf777f1..92bdf50d3 100644 --- a/src/libutil/util.hh +++ b/src/libutil/util.hh @@ -55,10 +55,6 @@ typedef list Paths; typedef set PathSet; -/* The canonical system name, as returned by config.guess. */ -extern string thisSystem; - - /* Return an environment variable. */ string getEnv(const string & key, const string & def = "");