aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/http-binary-cache-store.cc5
-rw-r--r--src/libstore/local-binary-cache-store.cc10
-rw-r--r--src/libstore/local-store.cc6
-rw-r--r--src/libstore/local-store.hh2
-rw-r--r--src/libstore/remote-store.cc6
-rw-r--r--src/libstore/remote-store.hh2
-rw-r--r--src/libstore/s3-binary-cache-store.cc5
-rw-r--r--src/libstore/store-api.cc21
-rw-r--r--src/libstore/store-api.hh7
9 files changed, 56 insertions, 8 deletions
diff --git a/src/libstore/http-binary-cache-store.cc b/src/libstore/http-binary-cache-store.cc
index 771eb42ee..392945ca7 100644
--- a/src/libstore/http-binary-cache-store.cc
+++ b/src/libstore/http-binary-cache-store.cc
@@ -85,7 +85,10 @@ protected:
};
-static RegisterStoreImplementation regStore([](const std::string & uri) -> std::shared_ptr<Store> {
+static RegisterStoreImplementation regStore([](
+ const std::string & uri, const StoreParams & params)
+ -> std::shared_ptr<Store>
+{
if (std::string(uri, 0, 7) != "http://" &&
std::string(uri, 0, 8) != "https://") return 0;
auto store = std::make_shared<HttpBinaryCacheStore>(std::shared_ptr<Store>(0),
diff --git a/src/libstore/local-binary-cache-store.cc b/src/libstore/local-binary-cache-store.cc
index 7968c98b9..2ec9a0d10 100644
--- a/src/libstore/local-binary-cache-store.cc
+++ b/src/libstore/local-binary-cache-store.cc
@@ -16,6 +16,11 @@ public:
void init() override;
+ std::string getUri() override
+ {
+ return "file://" + binaryCacheDir;
+ }
+
protected:
bool fileExists(const std::string & path) override;
@@ -78,7 +83,10 @@ ref<Store> openLocalBinaryCacheStore(std::shared_ptr<Store> localStore,
return store;
}
-static RegisterStoreImplementation regStore([](const std::string & uri) -> std::shared_ptr<Store> {
+static RegisterStoreImplementation regStore([](
+ const std::string & uri, const StoreParams & params)
+ -> std::shared_ptr<Store>
+{
if (std::string(uri, 0, 7) != "file://") return 0;
return openLocalBinaryCacheStore(std::shared_ptr<Store>(0),
settings.get("binary-cache-secret-key-file", string("")),
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 45ffbad67..01a11f11f 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -229,6 +229,12 @@ LocalStore::~LocalStore()
}
+std::string LocalStore::getUri()
+{
+ return "local";
+}
+
+
int LocalStore::getSchema()
{
int curSchema = 0;
diff --git a/src/libstore/local-store.hh b/src/libstore/local-store.hh
index abc4f719b..6f2341dec 100644
--- a/src/libstore/local-store.hh
+++ b/src/libstore/local-store.hh
@@ -87,6 +87,8 @@ public:
/* Implementations of abstract store API methods. */
+ std::string getUri() override;
+
bool isValidPathUncached(const Path & path) override;
PathSet queryValidPaths(const PathSet & paths) override;
diff --git a/src/libstore/remote-store.cc b/src/libstore/remote-store.cc
index 4663291b9..5a254a610 100644
--- a/src/libstore/remote-store.cc
+++ b/src/libstore/remote-store.cc
@@ -49,6 +49,12 @@ RemoteStore::RemoteStore(size_t maxConnections)
}
+std::string RemoteStore::getUri()
+{
+ return "daemon";
+}
+
+
ref<RemoteStore::Connection> RemoteStore::openConnection()
{
auto conn = make_ref<Connection>();
diff --git a/src/libstore/remote-store.hh b/src/libstore/remote-store.hh
index 4ea8e8a5b..8e45a7449 100644
--- a/src/libstore/remote-store.hh
+++ b/src/libstore/remote-store.hh
@@ -26,6 +26,8 @@ public:
/* Implementations of abstract store API methods. */
+ std::string getUri() override;
+
bool isValidPathUncached(const Path & path) override;
PathSet queryValidPaths(const PathSet & paths) override;
diff --git a/src/libstore/s3-binary-cache-store.cc b/src/libstore/s3-binary-cache-store.cc
index 6fadf7be2..cd88a3271 100644
--- a/src/libstore/s3-binary-cache-store.cc
+++ b/src/libstore/s3-binary-cache-store.cc
@@ -239,7 +239,10 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore
};
-static RegisterStoreImplementation regStore([](const std::string & uri) -> std::shared_ptr<Store> {
+static RegisterStoreImplementation regStore([](
+ const std::string & uri, const StoreParams & params)
+ -> std::shared_ptr<Store>
+{
if (std::string(uri, 0, 5) != "s3://") return 0;
auto store = std::make_shared<S3BinaryCacheStoreImpl>(std::shared_ptr<Store>(0),
settings.get("binary-cache-secret-key-file", string("")),
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 2763f5ad4..463e132e0 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -461,10 +461,22 @@ namespace nix {
RegisterStoreImplementation::Implementations * RegisterStoreImplementation::implementations = 0;
-ref<Store> openStoreAt(const std::string & uri)
+ref<Store> openStoreAt(const std::string & uri_)
{
+ auto uri(uri_);
+ StoreParams params;
+ auto q = uri.find('?');
+ if (q != std::string::npos) {
+ for (auto s : tokenizeString<Strings>(uri.substr(q + 1), "&")) {
+ auto e = s.find('=');
+ if (e != std::string::npos)
+ params[s.substr(0, e)] = s.substr(e + 1);
+ }
+ uri = uri_.substr(0, q);
+ }
+
for (auto fun : *RegisterStoreImplementation::implementations) {
- auto store = fun(uri);
+ auto store = fun(uri, params);
if (store) return ref<Store>(store);
}
@@ -478,7 +490,10 @@ ref<Store> openStore()
}
-static RegisterStoreImplementation regStore([](const std::string & uri) -> std::shared_ptr<Store> {
+static RegisterStoreImplementation regStore([](
+ const std::string & uri, const StoreParams & params)
+ -> std::shared_ptr<Store>
+{
enum { mDaemon, mLocal, mAuto } mode;
if (uri == "daemon") mode = mDaemon;
diff --git a/src/libstore/store-api.hh b/src/libstore/store-api.hh
index 87b8e8847..cdde0be7b 100644
--- a/src/libstore/store-api.hh
+++ b/src/libstore/store-api.hh
@@ -192,7 +192,7 @@ public:
virtual ~Store() { }
- virtual std::string getUri();
+ virtual std::string getUri() = 0;
/* Check whether a path is valid. */
bool isValidPath(const Path & path);
@@ -540,7 +540,10 @@ std::list<ref<Store>> getDefaultSubstituters();
/* Store implementation registration. */
-typedef std::function<std::shared_ptr<Store>(const std::string & uri)> OpenStore;
+typedef std::map<std::string, std::string> StoreParams;
+
+typedef std::function<std::shared_ptr<Store>(
+ const std::string & uri, const StoreParams & params)> OpenStore;
struct RegisterStoreImplementation
{