* Set the NIX_STORE and NIX_BUILD_TOP environment variables in
builders to point to the store and the temporary build directory, respectively. Useful for purity checking. * Also set TEMPDIR, TMPDIR, TEMP, and TEMP to NIX_BUILD_TOP to make sure that tools in the builder store temporary files in the right location.
This commit is contained in:
parent
7f0ed370da
commit
a5619f1dff
3 changed files with 19 additions and 3 deletions
|
@ -17,7 +17,7 @@ static string pathNullDevice = "/dev/null";
|
||||||
|
|
||||||
/* Run a program. */
|
/* Run a program. */
|
||||||
void runProgram(const string & program,
|
void runProgram(const string & program,
|
||||||
const Strings & args, const Environment & env,
|
const Strings & args, Environment env,
|
||||||
const string & logFileName)
|
const string & logFileName)
|
||||||
{
|
{
|
||||||
/* Create a log file. */
|
/* Create a log file. */
|
||||||
|
@ -32,10 +32,20 @@ void runProgram(const string & program,
|
||||||
|
|
||||||
/* Create a temporary directory where the build will take
|
/* Create a temporary directory where the build will take
|
||||||
place. */
|
place. */
|
||||||
string tmpDir = createTempDir();
|
Path tmpDir = createTempDir();
|
||||||
|
|
||||||
AutoDelete delTmpDir(tmpDir);
|
AutoDelete delTmpDir(tmpDir);
|
||||||
|
|
||||||
|
/* For convenience, set an environment pointing to the top build
|
||||||
|
directory. */
|
||||||
|
env["NIX_BUILD_TOP"] = tmpDir;
|
||||||
|
|
||||||
|
/* Also set TMPDIR and variants to point to this directory. */
|
||||||
|
env["TMPDIR"] = tmpDir;
|
||||||
|
env["TEMPDIR"] = tmpDir;
|
||||||
|
env["TMP"] = tmpDir;
|
||||||
|
env["TEMP"] = tmpDir;
|
||||||
|
|
||||||
/* Fork a child to build the package. */
|
/* Fork a child to build the package. */
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
switch (pid = fork()) {
|
switch (pid = fork()) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ typedef map<string, string> Environment;
|
||||||
|
|
||||||
/* Run a program. */
|
/* Run a program. */
|
||||||
void runProgram(const string & program,
|
void runProgram(const string & program,
|
||||||
const Strings & args, const Environment & env,
|
const Strings & args, Environment env,
|
||||||
const string & logFileName);
|
const string & logFileName);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -124,6 +124,12 @@ Path normaliseStoreExpr(const Path & _nePath, PathSet pending)
|
||||||
non-existing path. */
|
non-existing path. */
|
||||||
env["HOME"] = "/homeless-shelter";
|
env["HOME"] = "/homeless-shelter";
|
||||||
|
|
||||||
|
/* Tell the builder where the Nix store is. Usually they
|
||||||
|
shouldn't care, but this is useful for purity checking (e.g.,
|
||||||
|
the compiler or linker might only want to accept paths to files
|
||||||
|
in the store or in the build directory). */
|
||||||
|
env["NIX_STORE"] = nixStore;
|
||||||
|
|
||||||
/* Build the environment. */
|
/* Build the environment. */
|
||||||
for (StringPairs::iterator i = ne.derivation.env.begin();
|
for (StringPairs::iterator i = ne.derivation.env.begin();
|
||||||
i != ne.derivation.env.end(); i++)
|
i != ne.derivation.env.end(); i++)
|
||||||
|
|
Loading…
Reference in a new issue