aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-07-15 12:32:29 +0200
committerEelco Dolstra <edolstra@gmail.com>2022-07-15 12:32:29 +0200
commit3bcd7a5474f065a6e94a60b3042a0d42ed0184ec (patch)
tree1f9c5867bcac0961f0edf46b300a28112c896613 /src
parentde287964d5bf92cd811fce395061385c2079fba6 (diff)
Disable auto-chroot if $NIX_STATE_DIR is set
Issue #6732.
Diffstat (limited to 'src')
-rw-r--r--src/libstore/store-api.cc7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 45c53f23e..91dbd991e 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -1321,7 +1321,12 @@ std::shared_ptr<Store> openFromNonUri(const std::string & uri, const Store::Para
else if (pathExists(settings.nixDaemonSocketFile))
return std::make_shared<UDSRemoteStore>(params);
#if __linux__
- else if (!pathExists(stateDir) && params.empty() && getuid() != 0 && !getEnv("NIX_STORE_DIR").has_value()) {
+ else if (!pathExists(stateDir)
+ && params.empty()
+ && getuid() != 0
+ && !getEnv("NIX_STORE_DIR").has_value()
+ && !getEnv("NIX_STATE_DIR").has_value())
+ {
/* If /nix doesn't exist, there is no daemon socket, and
we're not root, then automatically set up a chroot
store in ~/.local/share/nix/root. */