How to cross-compile the SD Card images?

While I’m sure it’s far from idiomatic, searchers may be interested in my example below:

Points of interest include:

  • cross compiles an SD image that is bootable on an RPi3 with nix build
  • uses pkgs.vmTools.runInLinuxVM to create a subvolumed, compressed, BTRFS-root partition layout for the image
  • adds some customizations to uboot to support BTRFS and ZSTD compression
  • provides a booting VM target for local testing (though doesn’t do much other than boot – thread)
  • uses GitHub Actions to automatically build the image in CI (on tagged releases), and uploads the image to Releases · n8henrie/nixos-btrfs-pi · GitHub where then can be directly downloaded and burned to an SD card

I’m sure others will want to customize and probably take out a lot of cruft, but I’m blown away that this can all be done with nix + GitHub Actions, newbies (like myself) might find the example interesting.

4 Likes