1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +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

@ -24,7 +24,7 @@ TEST_F(nix_api_store_test, nix_store_get_uri)
std::string str;
auto ret = nix_store_get_uri(ctx, store, OBSERVE_STRING(str));
ASSERT_EQ(NIX_OK, ret);
auto expectedStoreURI = "local?"
auto expectedStoreURI = "local://?"
+ nix::encodeQuery({
{"log", nixLogDir},
{"state", nixStateDir},
@ -104,7 +104,7 @@ TEST_F(nix_api_util_context, nix_store_open_dummy)
nix_libstore_init(ctx);
Store * store = nix_store_open(ctx, "dummy://", nullptr);
ASSERT_EQ(NIX_OK, ctx->last_err_code);
ASSERT_STREQ("dummy", store->ptr->config.getUri().c_str());
ASSERT_STREQ("dummy://", store->ptr->config.getUri().c_str());
std::string str;
nix_store_get_version(ctx, store, OBSERVE_STRING(str));