Remote build hangs while copying path to remote box

I’ve a Raspberry Pi 4, 4GB running NixOS and a Ryzen 7 4800H laptop running archlinux, and I wish to build custom kernel for rpi using latter.
I’m at a point where I can run this remote build command on rpi successfully:

nix-build --expr '(with import <nixpkgs> { system = "aarch64-linux"; }; runCommand "foo" {} "uname > $out")' --builders 'ssh-ng://root@192.168.29.33 aarch64-linux'

On rpi, this is how I configure the builder

  nix = {
    extraOptions = ''
      builders-use-substitutes = true
    '';
    distributedBuilds = true;
    maxJobs = 0;
    buildMachines = [ { 
      hostName = "192.168.29.33";
      sshUser = "ssh-ng://root";
      sshKey = "/root/.ssh/id_ecdsa.pub";
      systems = ["x86_64-linux" "aarch64-linux"];
      maxJobs = 1;
      speedFactor = 2;
      supportedFeatures = [ "big-parallel" ];
      mandatoryFeatures = [ ];
    } ];
  };  

nixos-rebuild switch command gets stuck on copying

building Nix...
building the system configuration...
these derivations will be built:
  /nix/store/p5skldqf57h8jcl4gwffcfa7m6s3v2jj-linux-5.10.103-1.20220308.drv
  /nix/store/va9zwc3l6n1ahqhs265yssxxvkpmr1lq-firmware.drv
  /nix/store/1686xlravs183al0r3s206dp0bf0895l-etc-nixos.conf.drv
  /nix/store/3l8r9fd60293g2xys6fp0s27kkb2nkhg-kernel-modules.drv
  /nix/store/584028dzaaaxn7f7wrhkhm2n2z6s0pcs-etc-machines.drv
  /nix/store/59axm7hy3lrcdqfr1c84jxn51pjspb7v-etc.drv
  /nix/store/dm2859w9yiax78dnkw9s3y4jmm2kmqir-linux-5.10.103-1.20220308-modules.drv
  /nix/store/cmxjyiiwc0ki2mbymsj6cfy7grz4d608-linux-5.10.103-1.20220308-modules-shrunk.drv
  /nix/store/j1qz4h498pn307dylkgpyvxs68sf29j9-stage-1-init.sh.drv
  /nix/store/yj65ja915xsvp4sdsgk7lxmwklgjxvxi-initrd-linux-5.10.103-1.20220308.drv
  /nix/store/c4awi0ng4hl8apx95l6hink78avd84kl-nixos-system-vivy-21.11.336646.d2caa937753.drv
building '/nix/store/584028dzaaaxn7f7wrhkhm2n2z6s0pcs-etc-machines.drv'...
building '/nix/store/p5skldqf57h8jcl4gwffcfa7m6s3v2jj-linux-5.10.103-1.20220308.drv' on 'ssh-ng://root@192.168.29.33'...
copying 42 paths...
copying path '/nix/store/f0qrx5isjr46kv7iqpajiks1gdsmd5sk-source' to 'ssh-ng://root@192.168.29.33'...
copying path '/nix/store/hdr6v584ig3dpjlcs9afxxky3lvzm2nw-randstruct-provide-seed.patch' to 'ssh-ng://root@192.168.29.33'...

At this point, I’m sure that there’s no resource contention on rpi. As per nmon disk usage is mostly 0%, network transferring constantly at 100-200 KB/s. rpi and laptop are on local network. They can transfer at 50MB/s easily.
Also, the last thing: randstruct-provide-seed.patch is just a simple file.

I’ve tried with nix 2.7.0 and nix 2.3.16 on archlinux host, but both seem to get stuck.
If I run nixos-rebuild with -vvvvv then I see a huge spam of logs repeating the same 3 lines

building of '/nix/store/p5skldqf57h8jcl4gwffcfa7m6s3v2jj-linux-5.10.103-1.20220308.drv': read 91 bytes
waiting for children
sleeping 10 seconds
building of '/nix/store/p5skldqf57h8jcl4gwffcfa7m6s3v2jj-linux-5.10.103-1.20220308.drv': read 91 bytes
waiting for children
sleeping 10 seconds
...

Can anyone please suggest what might be the issue?

2 Likes

I’m facing exactly the same problem but on macOS (M1) with remote x86_64-linux builder.

Noticed that problem dissapears if I authenticate on remote builder as root. Weird, both root and my original users are listed in nix.settings.trusted-users.