1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 09:49:36 +01:00

libstore: Correct getUri methods for all stores

Previously `getUri` didn't include store query parameters,
`ssh-ng` didn't include any information at all and the local
store didn't have the path:

```
$ nix store info --store "local?root=/tmp/aaa&require-sigs=false"
Store URL: local
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh-ng://localhost?remote-program=nix-daemon"
Store URL: ssh-ng://
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh://localhost?remote-program=nix-store"
Store URL: ssh://localhost
```

This commit changes this to:

```
$ nix store info --store "local?root=/tmp/aaa&require-sigs=false"
Store URL: local?require-sigs=false&root=/tmp/aaa
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh-ng://localhost?remote-program=nix-daemon"
Store URL: ssh-ng://localhost?remote-program=nix-daemon
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh://localhost?remote-program=nix-store"
Store URL: ssh://localhost?remote-program=nix-store
```
This commit is contained in:
Sergei Zimmerman 2025-08-11 17:51:03 +03:00
parent 73ebdf2497
commit 41af531392
No known key found for this signature in database
7 changed files with 58 additions and 16 deletions

View file

@ -16,6 +16,7 @@
#include "nix/store/posix-fs-canonicalise.hh"
#include "nix/util/posix-source-accessor.hh"
#include "nix/store/keys.hh"
#include "nix/util/url.hh"
#include "nix/util/users.hh"
#include "nix/store/store-open.hh"
#include "nix/store/store-registration.hh"
@ -440,7 +441,13 @@ LocalStore::~LocalStore()
std::string LocalStore::getUri()
{
return "local";
std::ostringstream oss;
oss << *config->uriSchemes().begin();
auto queryParams = config->getQueryParams();
if (!queryParams.empty())
oss << "?";
oss << encodeQuery(queryParams);
return std::move(oss).str();
}
int LocalStore::getSchema()