about summary refs log tree commit diff
path: root/src/libstore/local-store.cc
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-31T09·19+0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-01-31T09·28+0100
commit9e7c1a4bbdbe6129dd9dc385776612c307d3d1bb (patch)
tree4c213493e9c6fa1045df1b4192061602e31c78eb /src/libstore/local-store.cc
parent4fa08f3edb413e65816441acfb6c3befee730a06 (diff)
Use the daemon when we don't have write access to the Nix database
Diffstat (limited to 'src/libstore/local-store.cc')
-rw-r--r--src/libstore/local-store.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 9199b12063a0..55bd3e70e7b8 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -397,9 +397,15 @@ int LocalStore::getSchema()
 }
 
 
+bool LocalStore::haveWriteAccess()
+{
+    return access(settings.nixDBPath.c_str(), R_OK | W_OK) == 0;
+}
+
+
 void LocalStore::openDB(bool create)
 {
-    if (access(settings.nixDBPath.c_str(), R_OK | W_OK))
+    if (!haveWriteAccess())
         throw SysError(format("Nix database directory ‘%1%’ is not writable") % settings.nixDBPath);
 
     /* Open the Nix database. */