about summary refs log tree commit diff
path: root/src/libmain
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2004-02-14T21·44+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2004-02-14T21·44+0000
commit76c0e85929dc747288a8fe66a7bb77673cf2aa7e (patch)
treea470529f9acd56ac6af84bf426628c33a8affebf /src/libmain
parent6f5a5ea5ea7fa80bc709c4a2b14ea4395ebe7469 (diff)
* The environment variable NIX_ROOT can now be set to execute Nix in a
  chroot() environment.
* A operation `--validpath' to register path validity.  Useful for
  bootstrapping in a pure Nix environment.
* Safety checks: ensure that files involved in store operations are in
  the store.

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;