Description
Is your feature request related to a problem? Please describe.
When deploying changes with deploy_nixos
a large portion of the deploy time is spent copying .drv files to the remote host. These files are very small, there are often very many of them, and round-trip latency ends up accounting for most of the time spent.
Describe the solution you'd like
According to #nixos on Matrix, the nix-copy-closure
protocol is "very chatty" (ie, has many round-trips) because it tries not to send any objects that the remote already has and it tries not to send anything that the remote doesn't already have all dependencies for.
When buildOnTarget
is set, deploy_nixos
runs nix-copy-closure
in nixos-deploy.sh
specifically to copy derivations only. Instead of using nix-copy-closure
in this case, it could perform an export, transfer the export, then perform an import. This would be a much less "chatty" exchange and largely eliminate the effects of round-trip latency. Since drvs are small, the penalty of possibly transferring some which do not need to be transferred is minimal. An entire NixOS system's drvs might amount to 30MB or 40MB.
This option could be guarded by a configuration toggle if there's some desire to put the choice about this trade-off into the end-user's hands.
Describe alternatives you've considered
None
Additional context
None