Skip to content

libstore: Correct getUri methods for all stores#13734

Merged
Mic92 merged 5 commits intoNixOS:masterfrom
xokdvium:get-uri-correct
Aug 11, 2025
Merged

libstore: Correct getUri methods for all stores#13734
Mic92 merged 5 commits intoNixOS:masterfrom
xokdvium:get-uri-correct

Conversation

@xokdvium
Copy link
Contributor

Motivation

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

Context

Fixes #11721
Resolves #11873

Best reviewed commit by commit.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This is necessary to make libstore-tests for store configs work again.
These headers need to be included before everything else
(at least in GCC).
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
```
@github-actions github-actions bot added store Issues and pull requests concerning the Nix store c api Nix as a C library with a stable interface labels Aug 11, 2025
@Mic92 Mic92 enabled auto-merge August 11, 2025 18:03
@Mic92 Mic92 merged commit dfb78af into NixOS:master Aug 11, 2025
12 checks passed
@xokdvium xokdvium deleted the get-uri-correct branch August 11, 2025 18:16
@Ericson2314
Copy link
Member

@xokdvium Should we make getUri return a ParsedURL now?

@xokdvium
Copy link
Contributor Author

@xokdvium Should we make getUri return a ParsedURL now?

Could be made to work, yeah.

@Mic92
Copy link
Member

Mic92 commented Aug 12, 2025

can be a bit verbose:

[eva] copying path '/nix/store/vizkynzvysir5jmj4a7mhbf1qkwgr974-source' to 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[turingmachine] restarting sysinit-reactivation.target
[turingmachine] reloading the following units: systemd-networkd.service
[turingmachine] starting the following units: sops-install-secrets.service, telegraf.service
[turingmachine] the following new units were started: NetworkManager-dispatcher.service, run-nixos\x2detc\x2dmetadata.Jx1aI3CDr3.mount
[turingmachine] /nix/store/yki1scrjfqxwkdg5s2n1zx9gl5y1nxjk-nixos-system-turingmachine-25.11.20250810.0100ac3
[turingmachine] Done. The new configuration is
[eva] copying 0 paths...
[eva] building '/nix/store/aikbbak7idc0j4smlq9pr27smxd3i648-manifest.json.drv'...
[eva] copying 0 paths...
[eva] building '/nix/store/x2lg212dgqlqpw9hlypls4smyba74y02-etc-nix-registry.json.drv'...
[eve] building '/nix/store/f378dsgyhmlsr6l65mgfh79l5ib3a98a-nixos-system-eve-25.11.20250810.0100ac3.drv'...
[eva] copying 0 paths...
[eva] building '/nix/store/4m3yk35sx4a4z8b74704jidqw5fbgrjb-unit-wireguard.network.drv'...
[eva] copying 1 paths...
[eva] copying 1 paths...
[eva] copying path '/nix/store/jzd1dp035qa5f3fs6izj7wpw3yclm394-manifest.json' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] copying path '/nix/store/k7jrifcg1k0wxd8s4xrq3j5jnf068lhg-etc-nix-registry.json' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] copying 1 paths...
[eva] building '/nix/store/j5q2p0sh3q43ixf4agsy353yac2l140i-flake-inputs.prom.drv'...
[eva] copying path '/nix/store/zadawpa7dfkhqwfppa5zj2d3l6drnvjp-unit-wireguard.network' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/f14w2slkf5jp687wqp53l4jc3h418lcw-X-Reload-Triggers-systemd-networkd.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/sg3jslwjvyaj7awvi480ml4ypdr6i1a0-flake-inputs.prom' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/dwj4bcgzfzisqpyk14z6i3jbkn842h47-config.toml.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/f14w2slkf5jp687wqp53l4jc3h418lcw-X-Reload-Triggers-systemd-networkd.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/wcp828x1vf3mgl5slyh00cjw1dc8f304-X-Reload-Triggers-systemd-networkd' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/x01r2fn9mscs2hbqdpy1sk5m9v9akj2m-unit-systemd-networkd.service.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/dwj4bcgzfzisqpyk14z6i3jbkn842h47-config.toml.drv'...
[eva] config.toml>
[eva] copying 1 paths...
[eva] copying path '/nix/store/pll31945vy7q0fp19xw0hpviig5j2m93-config.toml' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/nmsmh8m23hbdpp29w938ibvpr5z8qh7f-pre-start.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/x01r2fn9mscs2hbqdpy1sk5m9v9akj2m-unit-systemd-networkd.service.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/fv0wjqz3mncyqmxblbgmah2inax77hkd-unit-systemd-networkd.service' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] copying 0 paths...
[eva] building '/nix/store/nmsmh8m23hbdpp29w938ibvpr5z8qh7f-pre-start.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/px7f45gbw31nyzfcls37a6nwx55l718s-pre-start' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/jwvffkvd3nxi1if53zn5vnqgvb6zpxk7-unit-telegraf.service.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/jwvffkvd3nxi1if53zn5vnqgvb6zpxk7-unit-telegraf.service.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/yvnh1y53baw4smw6ckz2p8dcd2laz2m2-unit-telegraf.service' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/kyam2zyjjfb0ng72fw1zyw7g56wr7d0x-system-units.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/kyam2zyjjfb0ng72fw1zyw7g56wr7d0x-system-units.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/03zg9rzrcc48hxi7xwb32clhkbw6qw4f-system-units' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/yw205y9fhj935fvr82zyb1c1k5p7hkqb-etc.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/yw205y9fhj935fvr82zyb1c1k5p7hkqb-etc.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/dgimvs5nrv6drppqjisji9jdvhi75p7n-etc' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eva] building '/nix/store/2kgkvmmlw9w90k29ypi2405dkx4knn91-nixos-system-eva-25.11.20250810.0100ac3.drv' on 'ssh-ng://nix@yasmin'...
[eva] copying 0 paths...
[eva] building '/nix/store/2kgkvmmlw9w90k29ypi2405dkx4knn91-nixos-system-eva-25.11.20250810.0100ac3.drv'...
[eva] copying 1 paths...
[eva] copying path '/nix/store/6q3kq03rbkbcvyi8a6f2ivqhh7ziqmwj-nixos-system-eva-25.11.20250810.0100ac3' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...
[eve] --- diff to current-system

Probably more if you put public keys in there....

@Mic92
Copy link
Member

Mic92 commented Aug 12, 2025

I might actually prefer this:

[eva] building '/nix/store/nmsmh8m23hbdpp29w938ibvpr5z8qh7f-pre-start.drv' on 'ssh-ng://nix@yasmin'...

Over:

[eva] copying path '/nix/store/wcp828x1vf3mgl5slyh00cjw1dc8f304-X-Reload-Triggers-systemd-networkd' from 'ssh-ng://nix@yasmin?ssh-key=/run/secrets/ssh-tum-builder&system-features=big-parallel%20kvm%20nixos-test'...

@Mic92
Copy link
Member

Mic92 commented Aug 12, 2025

Maybe we can drop arguments and only print the user@host part?

@xokdvium
Copy link
Contributor Author

Maybe we can drop arguments and only print the user@host part?

Doing that only for the logs would be good, yeah. Something like getUri(bool concise).

@Ericson2314
Copy link
Member

My #13739 should make that easier, since it separates the rending logic from making the URL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c api Nix as a C library with a stable interface store Issues and pull requests concerning the Nix store

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Relocated store URI is reported as 'local', wrong nix copy's output does not include the correct store URL when copying to an ssh-ng store

3 participants