about summary refs log tree commit diff
path: root/src/libmain
diff options
context:
space:
mode:
Diffstat (limited to 'src/libmain')
-rw-r--r--src/libmain/shared.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libmain/shared.cc b/src/libmain/shared.cc
index 32f4f81240bb..ec639052b5c8 100644
--- a/src/libmain/shared.cc
+++ b/src/libmain/shared.cc
@@ -22,6 +22,13 @@ void sigintHandler(int signo)
    processor. */
 static void initAndRun(int argc, char * * argv)
 {
+    char * root = getenv("NIX_ROOT");
+
+    if (root) {
+        if (chroot(root) != 0)
+            throw SysError(format("changing root to `%1%'") % root);
+    }
+    
     /* Setup Nix paths. */
     nixStore = NIX_STORE_DIR;
     nixDataDir = NIX_DATA_DIR;