Use the daemon when we don't have write access to the Nix database
This commit is contained in:
parent
4fa08f3edb
commit
9e7c1a4bbd
7 changed files with 57 additions and 13 deletions
|
|
@ -311,10 +311,22 @@ std::shared_ptr<StoreAPI> store;
|
|||
|
||||
std::shared_ptr<StoreAPI> openStore(bool reserveSpace)
|
||||
{
|
||||
if (getEnv("NIX_REMOTE") == "")
|
||||
return std::shared_ptr<StoreAPI>(new LocalStore(reserveSpace));
|
||||
else
|
||||
return std::shared_ptr<StoreAPI>(new RemoteStore());
|
||||
enum { mDaemon, mLocal, mAuto } mode;
|
||||
|
||||
mode = getEnv("NIX_REMOTE") == "daemon" ? mDaemon : mAuto;
|
||||
|
||||
if (mode == mAuto) {
|
||||
if (LocalStore::haveWriteAccess())
|
||||
mode = mLocal;
|
||||
else if (pathExists(settings.nixDaemonSocketFile))
|
||||
mode = mDaemon;
|
||||
else
|
||||
mode = mLocal;
|
||||
}
|
||||
|
||||
return mode == mDaemon
|
||||
? (std::shared_ptr<StoreAPI>) std::make_shared<RemoteStore>()
|
||||
: std::make_shared<LocalStore>(reserveSpace);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue