about summary refs log tree commit diff
path: root/src/nix-env/user-env.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-02T11·33+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-06-02T14·02+0200
commit812c0dfbe24c8fe93992f77abbf1e5a975ea42f4 (patch)
treed69bcc87ce446f270f6b01f7069655223d52a626 /src/nix-env/user-env.cc
parentf2682e6e18a76ecbfb8a12c17e3a0ca15c084197 (diff)
Allow setting the state directory as a store parameter
E.g. "local?store=/tmp/store&state=/tmp/var".
Diffstat (limited to 'src/nix-env/user-env.cc')
-rw-r--r--src/nix-env/user-env.cc24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc
index ca27a7248107..f239f63776c2 100644
--- a/src/nix-env/user-env.cc
+++ b/src/nix-env/user-env.cc
@@ -131,18 +131,22 @@ bool createUserEnv(EvalState & state, DrvInfos & elems,
     state.store->buildPaths({topLevelDrv}, state.repair ? bmRepair : bmNormal);
 
     /* Switch the current user environment to the output path. */
-    PathLocks lock;
-    lockProfile(lock, profile);
+    auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
 
-    Path lockTokenCur = optimisticLockProfile(profile);
-    if (lockToken != lockTokenCur) {
-        printMsg(lvlError, format("profile ‘%1%’ changed while we were busy; restarting") % profile);
-        return false;
-    }
+    if (store2) {
+        PathLocks lock;
+        lockProfile(lock, profile);
+
+        Path lockTokenCur = optimisticLockProfile(profile);
+        if (lockToken != lockTokenCur) {
+            printMsg(lvlError, format("profile ‘%1%’ changed while we were busy; restarting") % profile);
+            return false;
+        }
 
-    debug(format("switching to new user environment"));
-    Path generation = createGeneration(state.store, profile, topLevelOut);
-    switchLink(profile, generation);
+        debug(format("switching to new user environment"));
+        Path generation = createGeneration(ref<LocalFSStore>(store2), profile, topLevelOut);
+        switchLink(profile, generation);
+    }
 
     return true;
 }