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.
This commit is contained in:
parent
015e1c2131
commit
e197bc6229
|
@ -864,7 +864,7 @@ StoreType getStoreType(const std::string & uri, const std::string & stateDir)
|
||||||
{
|
{
|
||||||
if (uri == "daemon") {
|
if (uri == "daemon") {
|
||||||
return tDaemon;
|
return tDaemon;
|
||||||
} else if (uri == "local" || hasPrefix(uri, "/")) {
|
} else if (uri == "local" || hasPrefix(uri, "/") || hasPrefix(uri, "./")) {
|
||||||
return tLocal;
|
return tLocal;
|
||||||
} else if (uri == "" || uri == "auto") {
|
} else if (uri == "" || uri == "auto") {
|
||||||
if (access(stateDir.c_str(), R_OK | W_OK) == 0)
|
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));
|
return std::shared_ptr<Store>(std::make_shared<UDSRemoteStore>(params));
|
||||||
case tLocal: {
|
case tLocal: {
|
||||||
Store::Params params2 = params;
|
Store::Params params2 = params;
|
||||||
if (hasPrefix(uri, "/"))
|
if (hasPrefix(uri, "/")) {
|
||||||
params2["root"] = uri;
|
params2["root"] = uri;
|
||||||
|
} else if (hasPrefix(uri, "./")) {
|
||||||
|
params2["root"] = absPath(uri);
|
||||||
|
}
|
||||||
return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2));
|
return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2));
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue