Allow setting the state directory as a store parameter

E.g. "local?store=/tmp/store&state=/tmp/var".
This commit is contained in:
Eelco Dolstra 2016-06-02 13:33:49 +02:00
parent f2682e6e18
commit 812c0dfbe2
13 changed files with 112 additions and 77 deletions

View file

@ -230,7 +230,7 @@ Path Store::computeStorePathForText(const string & name, const string & s,
Store::Store(const Params & params)
: storeDir(settings.nixStore)
: storeDir(get(params, "store", settings.nixStore))
{
}
@ -508,7 +508,8 @@ static RegisterStoreImplementation regStore([](
else return 0;
if (mode == mAuto) {
if (LocalStore::haveWriteAccess())
auto stateDir = get(params, "state", settings.nixStateDir);
if (access(stateDir.c_str(), R_OK | W_OK) == 0)
mode = mLocal;
else if (pathExists(settings.nixDaemonSocketFile))
mode = mDaemon;