Subject: Re: [PATCH] deploy: Support --target and --system.

From: Sergey Trofimov <[email-masked]>
Date: Fri, 21 Mar 2025 08:51:44 +0100

Hi Maxim,

Maxim Cournoyer <[email-masked]> writes:

> Hi Sergey,
>
> Sergey Trofimov <[email-masked]> writes:
>
> [...]
>
>>> Perhaps 'guix deploy' could have a '--cross-build' option, or the record
>>> could have a 'cross-build?' field, or both, with the CLI taking
>>> precedence over the later, and the target type would be inferred from
>>> the system via platform-system->target?
>>>
>>
>> Consider such case:
>>
>> deployer = x86_64, (aarch64 via binfmt)
>> builder1 = x86_64, (aarch64 via binfmt)
>> builder2 = aarch64, (x86_64 via binfmt)
>> remote1 = x86_64
>> remote2 = aarch64
>>
>> The user intends to run `guix deploy all-remotes.scm` on `deployer` to
>> deploy both `remote1` and `remote2`.
>>
>> There are many ways how to build the derivations - deployer and builders
>> could all build native/emulated/cross, remotes could build for
>> themselves (`build-locally?` to `#f`). I am not sure to what extent this
>> should be configurable, however here are a couple things I'd change:
>> - add `platform` to `machine` record
>> - remove `system` from `machine-ssh-configuration`
>> - remove `build-locally?` from `machine-ssh-configuration`
>> - add `build-options` to `machine`
>>   - `build-host` = `local|offload|remote`
>>   - `build-type` = `native|cross`
>
> This seems reasonable; I suppose 'remote' means the machine being
> deployed to?
>

That's right.

> `build-type` having just two values, it could be more simply expressed
> as a boolean (e.g.; cross-build?)
>

It's a matter of preference. Enums are extensible, bools are not.

>> Additionally `guix-daemon` should know all the systems the host
>> supports. Currently it knows only the native one (`--system` parameter).
>
> I've never used such feature, so I wouldn't know of how useful that
> would be :-).  Perhaps useful if the machine is to be used exclusively
> for cross-compiling by default?  You could also set that via 'export
> GUIX_BUILD_OPTIONS=--target=$gnu-triplet', no?

You've mentioned it in the previous mail:

> In my experience, assuming a powerful x86_64 workstation,
> cross-compilation > native-compilation (on lower spec ARM machine) >
> emulated native compilation (QEMU).

Cross compilation should be preferred when deploying from a powerful
machine to a smallest hetzner's ARM VM. The host is not used exclusively
for cross-building in such case.