about summary refs log tree commit diff
path: root/src/libstore/store-api.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-03T13·45+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-03T13·59+0200
commit5e51ffb1c265e16486fcdd888ce4a04db9e5552b (patch)
treeb19ff139061396af8c3013fd5522223c4b43f020 /src/libstore/store-api.hh
parent2f8b0e557b300f9b59f0b06778f6bc26aed6ba3f (diff)
Support sandbox builds by non-root users
This allows an unprivileged user to perform builds on a diverted store
(i.e. where the physical store location differs from the logical
location).

Example:

  $ NIX_LOG_DIR=/tmp/log NIX_REMOTE="local?real=/tmp/store&state=/tmp/var" nix-build -E \
    'with import <nixpkgs> {}; runCommand "foo" { buildInputs = [procps nettools]; } "id; ps; ifconfig; echo $out > $out"'

will do a build in the Nix store physically in /tmp/store but
logically in /nix/store (and thus using substituters for the latter).
Diffstat (limited to 'src/libstore/store-api.hh')
-rw-r--r--src/libstore/store-api.hh5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 7ef01ea93e..75caab7ea3 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -503,6 +503,11 @@ public:
         const Path & gcRoot, bool indirect, bool allowOutsideRootsDir = false);
 
     virtual Path getRealStoreDir() { return storeDir; }
+
+    Path toRealPath(const Path & storePath)
+    {
+        return getRealStoreDir() + "/" + baseNameOf(storePath);
+    }
 };