From d16fd2497374671c92cb877f9570d65783a77d99 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 24 Oct 2017 15:16:18 +0200 Subject: Allow shorter syntax for chroot stores You can now say '--store /tmp/nix' instead of '--store local?root=/tmp/nix'. --- src/libstore/store-api.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/libstore/store-api.cc') diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index 17237a03541c..c57e42fec00d 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -843,7 +843,7 @@ StoreType getStoreType(const std::string & uri, const std::string & stateDir) { if (uri == "daemon") { return tDaemon; - } else if (uri == "local") { + } else if (uri == "local" || hasPrefix(uri, "/")) { return tLocal; } else if (uri == "" || uri == "auto") { if (access(stateDir.c_str(), R_OK | W_OK) == 0) @@ -865,8 +865,12 @@ static RegisterStoreImplementation regStore([]( switch (getStoreType(uri, get(params, "state", settings.nixStateDir))) { case tDaemon: return std::shared_ptr(std::make_shared(params)); - case tLocal: - return std::shared_ptr(std::make_shared(params)); + case tLocal: { + Store::Params params2 = params; + if (hasPrefix(uri, "/")) + params2["root"] = uri; + return std::shared_ptr(std::make_shared(params2)); + } default: return nullptr; } -- cgit 1.4.1