Nixos-rebuild remote deploy from substituter

I am on host a, and I have the derivation for a host I want to deploy locally:

$ nix path-info --derivation

I do not have the output locally:

$ nix show-derivation /nix/store/bwpbwbrm4sni09gwqwapvdi3z46g0711-nixos-system-loogle-23.11.20230606.af21c31.drv | jq -r '.[].outputs.out.path'
# ls /nix/store/mb13r407vhf3gy4vj9b6nvizmgjm64p8-nixos-system-loogle-23.11.20230606.af21c31
ls: cannot access '/nix/store/mb13r407vhf3gy4vj9b6nvizmgjm64p8-nixos-system-loogle-23.11.20230606.af21c31': No such file or directory

But it is available in a substituter:

$ nix store ls -d --store  /nix/store/mb13r407vhf3gy4vj9b6nvizmgjm64p8-nixos-system-loogle-23.11.20230606.af21c31

How can I invoke nixos-rebuild so that

  • the derivation isn’t pushed to the other side (no need to pull in all the sources it depends upon)
  • the output path is fetched from the substituter (which is configured remotely)

It seems that

nixos-rebuild switch --use-substitutes --target-host  --flake .#loogle --fast

will pointlessly build the system locally (by fetching it from the substitutor), while

nixos-rebuild switch --use-substitutes --build-host --target-host  --flake .#loogle --fast

insists on (pointlessly) uploading the .drv to the remote host first.

I guess I can do some of the steps that nixos-rebuild does manually; once I have the output name

$ nix-env -p /nix/var/nix/profiles/system --set /nix/store/mb13r407vhf3gy4vj9b6nvizmgjm64p8-nixos-system-loogle-23.11.20230606.af21c31

will nicely fetch it (on the remote host), and then I just have to run

$ /nix/store/mb13r407vhf3gy4vj9b6nvizmgjm64p8-nixos-system-loogle-23.11.20230606.af21c31/bin/switch-to-configuration switch

it seems.

Is this too much of a corner case to be supported more directly?


1 Like