about summary refs log tree commit diff
path: root/src/libstore/store-api.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore/store-api.cc')
-rw-r--r--src/libstore/store-api.cc18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 82872cc335e3..f9c8767709e7 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -313,18 +313,24 @@ void Store::exportPaths(const Paths & paths,
 
 
 #include "local-store.hh"
-#include "serialise.hh"
 #include "remote-store.hh"
+#include "local-binary-cache-store.hh"
 
 
 namespace nix {
 
 
-ref<Store> openStore(bool reserveSpace)
+ref<Store> openStoreAt(const std::string & uri, bool reserveSpace)
 {
+    if (std::string(uri, 0, 7) == "file://") {
+        return make_ref<LocalBinaryCacheStore>(std::shared_ptr<Store>(0),
+            "", "", // FIXME: allow the signing key to be set
+            std::string(uri, 7));
+    }
+
     enum { mDaemon, mLocal, mAuto } mode;
 
-    mode = getEnv("NIX_REMOTE") == "daemon" ? mDaemon : mAuto;
+    mode = uri == "daemon" ? mDaemon : mAuto;
 
     if (mode == mAuto) {
         if (LocalStore::haveWriteAccess())
@@ -341,4 +347,10 @@ ref<Store> openStore(bool reserveSpace)
 }
 
 
+ref<Store> openStore(bool reserveSpace)
+{
+    return openStoreAt(getEnv("NIX_REMOTE"), reserveSpace);
+}
+
+
 }