Hello,
I am trying to cross-build an SD card image to boot a raspberrypi3.
My experiment is available at GitHub - gautaz/phoenix at raspberrypi and is flake based.
My current build process follows:
❯ nix-shell
phoenix on raspberrypi [!] via ❄️ impure (phoenix)
❯ phx-build echidna
warning: Git tree '/home/del/github.com/gautaz/phoenix' is dirty
error: builder for '/nix/store/n8xalnwdi24ay0j5km5rakjjky1grhs7-nixos-sd-image-23.11.20231017.e585645-armv7l-linux.img-armv7l-unknown-linux-gnueabihf.drv' failed with exit code 1;
last 10 log lines:
> /nix/store/xn9s6irhj753nckqbwvlldikjapx7xma-nixos-sd-image-23.11.20231017.e585645-armv7l-linux.img-armv7l-unknown-linux-gnueabihf/sd-image/nixos-sd-image-23.11.20231017.e585645-armv7l-linux.img1 16384 77823 61440 30M b W95
> /nix/store/xn9s6irhj753nckqbwvlldikjapx7xma-nixos-sd-image-23.11.20231017.e585645-armv7l-linux.img-armv7l-unknown-linux-gnueabihf/sd-image/nixos-sd-image-23.11.20231017.e585645-armv7l-linux.img2 * 77824 4138815 4060992 1.9G 83 Linu
>
> The partition table has been altered.
> Syncing disks.
> 4060992+0 records in
> 4060992+0 records out
> 2079227904 bytes (2.1 GB, 1.9 GiB) copied, 5.12259 s, 406 MB/s
> mkfs.fat 4.2 (2021-01-31)
> cp: cannot create regular file 'firmware/config.txt': Permission denied
For full logs, run 'nix log /nix/store/n8xalnwdi24ay0j5km5rakjjky1grhs7-nixos-sd-image-23.11.20231017.e585645-armv7l-linux.img-armv7l-unknown-linux-gnueabihf.drv'.
So the process currently fails during the populateFirmwareCommands
step, in particular on https://github.com/gautaz/phoenix/blob/99c92502a35de61a0e9daa8e3b5937248c280400/sd-image-raspberrypi.nix#L26:
cp ${configTxt} firmware/config.txt
The whole process succeeds without populateFirmwareCommands
but this will in fact result in an SD card image with an empty firmware partition.
I initially looked at examples like https://github.com/NixOS/nixpkgs/blob/189d2641716be9b862f9619bb3948a7e25f62f41/nixos/modules/installer/sd-card/sd-image-aarch64.nix to grasp what should be the “standard way” to provision the firmware partition but I am not sure this is applicable in a cross-compilation context.
Looking at https://github.com/n8henrie/nixos-btrfs-pi/blob/82df1c61560ece8f95e33ac375468dac38f24a0d/btrfs-sd-image.nix#L298, it seems @n8henrie needs to mount the firmware partition manually.
This feels strange as I would have expected the populateFirmwareCommands
to be executed in a context where the firmware partition would already be mounted and available for provisioning.
In fact, looking at the build logs, the partition has been formatted (mkfs.fat 4.2
) but does not seem to be mounted afterwards.
Is this missing intentionally?
If so:
- Why?
- What command should be issued in
populateFirmwareCommands
to mount the firmware partition?
Ismount /dev/disk/by-label/${firmwarePartOpts.firmwarePartName} /tmp/firmware
the right way to do it?
If anyone could shed some light on how populateFirmwareCommands
should be used in a cross-compilation context, it would save my day .