about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2008-12-12T17·14+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2008-12-12T17·14+0000
commit92cb7c4dfe036ed4c13d45128a21838a039d840f (patch)
tree24adccb1a893ef5d7f4f0321f47cc2b6054810d4 /src/libstore/build.cc
parent0008b0006db59ea8fccfe041cf8d87f05abb427d (diff)
* Put chroots in the Nix store. This ensures that we can create hard
  links to the inputs.

Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 8d06a66f6094..54890afd180c 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -811,6 +811,11 @@ void DerivationGoal::haveDerivation()
         return;
     }
 
+    /* `drvPath' should already be a root, but let's be on the safe
+       side: if the user forgot to make it a root, we wouldn't want
+       things being garbage collected while we're busy. */
+    worker.store.addTempRoot(drvPath);
+    
     assert(worker.store.isValidPath(drvPath));
 
     /* Get the derivation. */
@@ -1669,8 +1674,10 @@ void DerivationGoal::startBuilder()
     if (useChroot) {
 #if CHROOT_ENABLED
         /* Create a temporary directory in which we set up the chroot
-           environment using bind-mounts. */
-        chrootRootDir = createTempDir("", "nix-chroot");
+           environment using bind-mounts.  We put it in the Nix store
+           to ensure that we can create hard-links to non-directory
+           inputs in the fake Nix store in the chroot (see below). */
+        chrootRootDir = drvPath + ".chroot";
 
         /* Clean up the chroot directory automatically. */
         autoDelChroot = boost::shared_ptr<AutoDelete>(new AutoDelete(chrootRootDir));