Hello. I recently discovered that offloading builds to remote machines[1], hangs when the machines are not available; instead of defaulting to building locally[2]. This forces the user to use the `--no-offload` flag.
I saw in the mailing list[2] that someone suggested that, the `build-machines` field accepts a list of GEXPs instead of plain `build-machine` record types. This suggestion is almost correct but it only checks if the host is known which does not guarantee that it is reachable. Therefore I came up with this: --8<---------------cut here---------------start------------->8--- (build-machines (list #~(let* ((resolvable? (lambda (machine) (zero? (system* #$(file-append netcat "/bin/nc") "-z" "-w1" (build-machine-name machine) "22"))))) (filter resolvable? (list (build-machine (name "my-host") (systems (list "x86_64-linux" "i686-linux")) ;; NOTE: Located in '/etc/ssh/ssh_host_ed25519_key.pub' on the machine that does the build. ;; It will be generated by `openssh-service-type'. (host-key #$(plain-file-content %my-host-host-key)) ;; NOTE: User on the build machine that allows SSH access with the key from `private-key' field. (user "my-host-user1") (private-key "/home/user1/.ssh/id_ed25519"))))))) --8<---------------cut here---------------end--------------->8--- Which allows to dynamically detect which machines are reachable. If the user wanted to never build locally, the `-M 0` flag can be used. Therefore, I would expect that it would graciously fallback to building locally instead of getting stuck. If this is the desired behaviour, I think we should document how to avoid the hanging. Should we add this snippet to the manual/cookbook? [1] https://guix.gnu.org/manual/en/html_node/Daemon-Offload-Setup.html [2] https://lists.gnu.org/archive/html/help-guix/2023-12/msg00114.html [3] https://lists.gnu.org/archive/html/help-guix/2023-12/msg00120.html Regards, Sergio.