Subject: [bug#77033] [PATCH] deploy: Support --target and --system.

From: Roman Scherer <[email-masked]>
Date: Fri, 21 Mar 2025 10:15:51 +0100

Hi Sergey,

I just tried this patch with the following machine config:

```
(use-modules (gnu machine)
             (gnu machine hetzner))

(list
 (machine
  (operating-system %hetzner-os-x86)
  (environment hetzner-environment-type)
  (configuration (hetzner-configuration
                  (server-type "cpx41")
                  (ssh-key "/home/roman/workspace/guix/id_rsa")))))
```

I deployed it with the following command:

```
./pre-inst-env guix deploy hetzner-minimal.scm --no-offload --timeout=864000 --max-silent-time=864000
```

The server gets created, the Guix bootstrap system is installed on it,
but when it tries to apply the final operating system config it "hangs"
at applying grafts:

```
...
guix system: bootloader successfully installed on /dev/sda
successfully installed guix operating system on 'guix-x86'
rebooting server for 'guix-x86'...
successfully rebooted server for 'guix-x86'
connecting via SSH to '138.201.175.151' using '/home/roman/workspace/guix/id_rsa'...
SSH connection to '138.201.175.151' port 22 failed: Timeout connecting to 138.201.175.151
guix deploy: warning: <machine-ssh-configuration> without a 'host-key' is deprecated
substitute: looking for substitutes on 'https://substitutes.asahi-guix.org'... 100.0%
substitute: looking for substitutes on 'https://substitutes.nonguix.org'... 100.0%
substitute: looking for substitutes on 'https://bordeaux.guix.gnu.org'... 100.0%
substitute: looking for substitutes on 'https://ci.guix.gnu.org'... 100.0%
The following derivations will be built:
  /gnu/store/f3s4as9imjy6mbpgq8796q64hm82ykaf-remote-assertion.scm.drv
  /gnu/store/14cba7yngalx7375gdh5325ba5ss1igh-module-import-compiled.drv
  /gnu/store/ipqcb48n8jhc11y7b1pbxaf4nxdv27iv-remote-assertion.scm.drv
  /gnu/store/q49sc3kk2f3430dmcsd4lbqgran1w8il-remote-assertion.scm.drv
  /gnu/store/8wdvxf30pn3m0i7six8s5v02iw0h8hl4-remote-exp.scm.drv

applying 2 grafts for bash-minimal-5.1.16 ...
-
```

SSHing into the machine doesn't show much activity. The "-" on the last line
is also not spinning, so I'm wondering if it actually does something or if it
waits on something. The "-" not spinning I also observed when I did the cross
build with your other patch.

Applying grafts doesn't take so long in what I have observed.

Deploying this arm machine from an aarch64 system works with your patch though.

```
(list (machine
       (operating-system %hetzner-os-arm)
       (environment hetzner-environment-type)
       (configuration (hetzner-configuration
                       (server-type "cax21")
                       (ssh-key "/home/roman/workspace/guix/id_rsa")))))
```

Any ideas why it is hanging at applying the grafts?

Roman

Sergey Trofimov <[email-masked]> writes:

> Roman Scherer <[email-masked]> writes:
>
>> Hello Sergey,
>>
>> this looks good to me and is better than what we have now. I'm testing
>> this right now and will report back when it went through ...
>>
>
> I think this patch is not necessary at all, your code already sets the
> `system` field of `machine-ssh-configuration` to the value appropriate
> to one returned by hetzner-api.
>
> It looks to me that the bug is in incorrect parameterization, see the
> following patch. I've been able to deploy using it (again
> `build-locally?` set to #f as it takes too long otherwise). Please test
> this one.
>
> --8<---------------cut here---------------start------------->8---
> From 988d192cfe4833761d0714aa8a53392c09dd5c9d Mon Sep 17 00:00:00 2001
> Message-ID: <[email-masked]>
> From: Sergey Trofimov <[email-masked]>
> Subject: [PATCH] machine: ssh: Use monadic parameterize for monads.
>
> * gnu/machine/ssh (deploy-managed-host): Use store-parameterize in
> monadic context.
>
> Change-Id: I6441a5dac856633f2c2a00b77f21a385bf3a9510
> ---
>  gnu/machine/ssh.scm | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/gnu/machine/ssh.scm b/gnu/machine/ssh.scm
> index 73d5dc513e..0ce2860236 100644
> --- a/gnu/machine/ssh.scm
> +++ b/gnu/machine/ssh.scm
> @@ -542,8 +542,8 @@ (define (deploy-managed-host machine)
>                                          host
>                                          (inferior-exception-arguments c))))
>                                os))
> -          (parameterize ((%current-system system)
> -                         (%current-target-system #f))
> +          (store-parameterize ((%current-system system)
> +                               (%current-target-system #f))
>              (with-roll-back #t
>                (mbegin %store-monad
>                  (upgrade-shepherd-services (eval/error-handling c
>
> base-commit: df799a61ef73451e587cb81942c7bfcbbade9e7e