about summary refs log tree commit diff
path: root/src/libstore/exec.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/exec.cc')
-rw-r--r--src/libstore/exec.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/libstore/exec.cc b/src/libstore/exec.cc
index 01577143dc9e..31a2bae81ab7 100644
--- a/src/libstore/exec.cc
+++ b/src/libstore/exec.cc
@@ -17,7 +17,7 @@ static string pathNullDevice = "/dev/null";
 
 /* Run a program. */
 void runProgram(const string & program, 
-    const Strings & args, const Environment & env,
+    const Strings & args, Environment env,
     const string & logFileName)
 {
     /* Create a log file. */
@@ -32,10 +32,20 @@ void runProgram(const string & program,
 
     /* Create a temporary directory where the build will take
        place. */
-    string tmpDir = createTempDir();
+    Path tmpDir = createTempDir();
 
     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. */
     pid_t pid;
     switch (pid = fork()) {