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:
parent
3e4bdfedee
commit
031d70e500
4 changed files with 66 additions and 46 deletions
|
|
@ -1862,6 +1862,7 @@ void DerivationGoal::startBuilder()
|
|||
dirsInChroot[i] = r;
|
||||
else {
|
||||
Path p = chrootRootDir + i;
|
||||
debug("linking ‘%1%’ to ‘%2%’", p, r);
|
||||
if (link(r.c_str(), p.c_str()) == -1) {
|
||||
/* Hard-linking fails if we exceed the maximum
|
||||
link count on a file (e.g. 32000 of ext3),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -668,20 +668,31 @@ void removeTempRoots();
|
|||
/* Return a Store object to access the Nix store denoted by
|
||||
‘uri’ (slight misnomer...). Supported values are:
|
||||
|
||||
* ‘direct’: The Nix store in /nix/store and database in
|
||||
* ‘local’: The Nix store in /nix/store and database in
|
||||
/nix/var/nix/db, accessed directly.
|
||||
|
||||
* ‘daemon’: The Nix store accessed via a Unix domain socket
|
||||
connection to nix-daemon.
|
||||
|
||||
* ‘auto’ or ‘’: Equivalent to ‘local’ or ‘daemon’ depending on
|
||||
whether the user has write access to the local Nix
|
||||
store/database.
|
||||
|
||||
* ‘file://<path>’: A binary cache stored in <path>.
|
||||
|
||||
If ‘uri’ is empty, it defaults to ‘direct’ or ‘daemon’ depending on
|
||||
whether the user has write access to the local Nix store/database.
|
||||
set to true *unless* you're going to collect garbage. */
|
||||
ref<Store> openStore(const std::string & uri = getEnv("NIX_REMOTE"));
|
||||
* ‘https://<path>’: A binary cache accessed via HTTP.
|
||||
|
||||
ref<Store> openStore(const std::string & uri, const Store::Params & params);
|
||||
* ‘s3://<path>’: A writable binary cache stored on Amazon's Simple
|
||||
Storage Service.
|
||||
|
||||
* ‘ssh://[user@]<host>’: A remote Nix store accessed by running
|
||||
‘nix-store --serve’ via SSH.
|
||||
|
||||
You can pass parameters to the store implementation by appending
|
||||
‘?key=value&key=value&...’ to the URI.
|
||||
*/
|
||||
ref<Store> openStore(const std::string & uri = getEnv("NIX_REMOTE"),
|
||||
const Store::Params & extraParams = Store::Params());
|
||||
|
||||
|
||||
void copyPaths(ref<Store> from, ref<Store> to, const PathSet & storePaths, bool substitute = false);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue