1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 04:21:16 +02:00

Support arbitrary store URIs in nix.machines

For backwards compatibility, if the URI is just a hostname, ssh://
(i.e. LegacySSHStore) is prepended automatically.

Also, all fields except the URI are now optional. For example, this is
a valid nix.machines file:

  local?root=/tmp/nix

This is useful for testing the remote build machinery since you don't
have to mess around with ssh.
This commit is contained in:
Eelco Dolstra 2017-05-01 17:35:30 +02:00
parent 3e4bdfedee
commit 031d70e500
No known key found for this signature in database
GPG key ID: 8170B4726D7198DE
4 changed files with 66 additions and 46 deletions

View file

@ -709,10 +709,11 @@ namespace nix {
RegisterStoreImplementation::Implementations * RegisterStoreImplementation::implementations = 0;
ref<Store> openStore(const std::string & uri_)
ref<Store> openStore(const std::string & uri_,
const Store::Params & extraParams)
{
auto uri(uri_);
Store::Params params;
Store::Params params(extraParams);
auto q = uri.find('?');
if (q != std::string::npos) {
for (auto s : tokenizeString<Strings>(uri.substr(q + 1), "&")) {
@ -722,11 +723,7 @@ ref<Store> openStore(const std::string & uri_)
}
uri = uri_.substr(0, q);
}
return openStore(uri, params);
}
ref<Store> openStore(const std::string & uri, const Store::Params & params)
{
for (auto fun : *RegisterStoreImplementation::implementations) {
auto store = fun(uri, params);
if (store) {
@ -735,7 +732,7 @@ ref<Store> openStore(const std::string & uri, const Store::Params & params)
}
}
throw Error(format("don't know how to open Nix store %s") % uri);
throw Error("don't know how to open Nix store %s", uri);
}