1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-12-17 22:41:08 +01:00

Rewrite StoreConfig::getUri in terms of new StoreConfig::getReference

Rather than having store implementations return a free-form URI string,
have them return a `StoreReference`. This reflects that fact that this
method is supposed to invert `resolveStoreConfig`, which goes from a
`StoreReference` to some `StoreConfig` concrete derived class (based on
the registry).

`StoreConfig::getUri` is kept only as a convenience for the common case
that we want to immediately render the `StoreReference`.

A few tests were changed to use `local://` not `local`, since
`StoreReference` does not encode the `local` and `daemon` shorthands
(and instead desugars them to `local://` and `unix://` right away). I
think that is fine. `local` and `daemon` still work as input.
This commit is contained in:
John Ericson 2025-08-12 10:50:45 -04:00
parent be3a508b74
commit 3e7879e6df
22 changed files with 181 additions and 60 deletions

View file

@ -54,14 +54,19 @@ UDSRemoteStore::UDSRemoteStore(ref<const Config> config)
{
}
std::string UDSRemoteStoreConfig::getUri() const
StoreReference UDSRemoteStoreConfig::getReference() const
{
return path == settings.nixDaemonSocketFile ? // FIXME: Not clear why we return daemon here and not default
// to settings.nixDaemonSocketFile
//
// unix:// with no path also works. Change what we return?
"daemon"
: std::string(*uriSchemes().begin()) + "://" + path;
return {
.variant =
StoreReference::Specified{
.scheme = *uriSchemes().begin(),
// We return the empty string when the path looks like the
// default path, but we could also just return the path
// verbatim always, to be robust to overall config changes
// at the cost of some verbosity.
.authority = path == settings.nixDaemonSocketFile ? "" : path,
},
};
}
void UDSRemoteStore::Connection::closeWrite()