I have 2 computers at home with nearly identical configurations. To save bandwidth, I had the idea to update one (which took 20 minutes) and then use nixos-rebuild switch --use-remote-sudo --target-host $host --flake ".#$host"
to copy the derivations to the second computer.
copying 2861 paths...
copying path '/nix/store/013yilq34lcbwb393h4fba4s76gydrbp-zram-generator.conf' to 'ssh://remote'...
...
However, this is horribly slow. I just aborted the whole thing after 3.5 hours. Then did a normal nixos-rebuild switch on the second computer, which took 17 minutes.
Why is it faster to download all derivations from the internet than copying it over lan?
I’m using a similar setup here. I first nix build the second system closure on the first system, the nix copy it to the second system, copy flake.{nix,lock}, the do nixos-rebuild switch --target-host ....
I also observed that if the second machine is reachable via WiFi and Ethernet ssh can get confused by the Hostname/IP mapping and copying is very slow.
Revisiting this for the ~4th time. Things haven’t changed significantly here are two versions of copy you could be using.
# just following the manual slow:
## --no-check-sigs can be removed if signing is setup correctly
nix copy --no-check-sigs --from 'ssh-ng://<server>' <store-path>
# lix equivalent, still slow
nix-copy-closure --from '<server>' --log-format bar <store-path>
nix-copy-closure has an additional --gip flag that speeds things up. That flag is just tacking ssh builtin compression onto the ssh url. That’s good news as either Compression yes in .ssh/config or --from 'ssh-ng://<server>?compress=true' when manually calling the command both significantly improve the transfer speed.
The bulk transfer strategy referenced above may still be faster. This is minor change just isn’t in the manual (or is assumed).