From 5e51ffb1c265e16486fcdd888ce4a04db9e5552b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 3 Jun 2016 15:45:11 +0200 Subject: 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 {}; 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). --- src/libstore/store-api.hh | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/libstore/store-api.hh') diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh index 7ef01ea93ed0..75caab7ea388 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); + } }; -- cgit 1.4.1