diff options
author | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-06-23 11:12:01 -0400 |
---|---|---|
committer | Carlo Nucera <carlo.nucera@protonmail.com> | 2020-06-23 11:13:18 -0400 |
commit | e197bc622948973fca192774b6cd8e0d3157aeb6 (patch) | |
tree | c3dffa2faaa0538359c4296c596cbe476ea1880a /src | |
parent | 015e1c2131de938d61fa50c8df9d3987c42bcb39 (diff) |
Enable the --store option to take relative paths
In nix commands which accept --store options, we can now specify a
relative path, which will be canonicalized.
Diffstat (limited to 'src')
-rw-r--r-- | src/libstore/store-api.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc index e4a4ae11e..42ffa3ddb 100644 --- a/src/libstore/store-api.cc +++ b/src/libstore/store-api.cc @@ -864,7 +864,7 @@ StoreType getStoreType(const std::string & uri, const std::string & stateDir) { if (uri == "daemon") { return tDaemon; - } else if (uri == "local" || hasPrefix(uri, "/")) { + } else if (uri == "local" || hasPrefix(uri, "/") || hasPrefix(uri, "./")) { return tLocal; } else if (uri == "" || uri == "auto") { if (access(stateDir.c_str(), R_OK | W_OK) == 0) @@ -888,8 +888,11 @@ static RegisterStoreImplementation regStore([]( return std::shared_ptr<Store>(std::make_shared<UDSRemoteStore>(params)); case tLocal: { Store::Params params2 = params; - if (hasPrefix(uri, "/")) + if (hasPrefix(uri, "/")) { params2["root"] = uri; + } else if (hasPrefix(uri, "./")) { + params2["root"] = absPath(uri); + } return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2)); } default: |