about summary refs log tree commit diff
path: root/src/libstore/build.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-02T13·08+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-02T14·02+0200
commit4494000e04122f24558e1436e66d20d89028b4bd (patch)
tree4d8bb49449aa6f8611a05c96bc9d7342430232f2 /src/libstore/build.cc
parent064816ab98e7a230b6e9f4071353f5172e70cf03 (diff)
LocalStore: Allow the physical and logical store directories to differ
This is primarily to subsume the functionality of the
copy-from-other-stores substituter. For example, in the NixOS
installer, we can now do (assuming we're in the target chroot, and the
Nix store of the installation CD is bind-mounted on /tmp/nix):

  $ nix-build ... --option substituters 'local?state=/tmp/nix/var&real=/tmp/nix/store'

However, unlike copy-from-other-stores, this also allows write access
to such a store. One application might be fetching substitutes for
/nix/store in a situation where the user doesn't have sufficient
privileges to create /nix, e.g.:

  $ NIX_REMOTE="local?state=/home/alice/nix/var&real=/home/alice/nix/store" nix-build ...
Diffstat (limited to 'src/libstore/build.cc')
-rw-r--r--src/libstore/build.cc3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index f232fe86a967..3233a8d5cd2a 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1269,6 +1269,9 @@ void DerivationGoal::tryToBuild()
 {
     trace("trying to build");
 
+    if (worker.store.storeDir != worker.store.realStoreDir)
+        throw Error("building with a diverted Nix store is not supported");
+
     /* Check for the possibility that some other goal in this process
        has locked the output since we checked in haveDerivation().
        (It can't happen between here and the lockPaths() call below