This is an experiment in using Nix to build reproducible images for embedded systems using cross-compilation.
It uses disko and
nixos-anywhere for initial
deployment and target systems can later be updated via a remote nixos-rebuild
Currently the only defined target is Beaglebone Black
The following images are available:
bbb-standardA generic image usingpine-bbb-standard-sdbbb-sd-installerA minimal image for installing to the internal emmc
The flake can build the following NixOs configurations
-
pine-bbb-installerA minimal installer config, not to be used directly but for building SD card image. -
pine-bbb-standard-sdA config for running of the sd-card, can be basis for a custom config. -
pine-bbb-standard-emmcA config for running of BeagleBone internal emmc meant to be written usingnixos-anywherewhen runningsd-installerof the SD card
Important
Most of the building is done cross compiled but some steps (disko) uses QEMU
this requires running armv7l-linux code using binfmt, in NixOS set
binfmt.emulatedSystems = [ "armv7l-linux" ]; otherwise building won't work,
for other distros check documentation
- Build and run the image generator
nix build .#images.bbb-standard
./result
- Write to sd-card use dd or bmaptool
sudo bmaptool copy ./pine-sdcard.raw /dev/<SD-card>
- Build and run the installer image generator
nix build .#images.bbb-installer
./result
- write to sd-card use dd or bmaptool
sudo bmaptool copy ./pine-installer-sdcard.raw /dev/<SD-card>
-
Boot from the SD Card
-
Install to emmc using nixos-anywhere
- Figure out the IP of the board (
ip a) - Login is 'pine'/'pass' and ssh is enabled
- Figure out the IP of the board (
nix run .#nixos-anywhere -- --flake .#pine-bbb-standard-emmc --target-host pine@<target-ip> --build-on local
nixos-rebuild <switch or boot> --flake .#<nixosConfiguration> --target-host pine@<target-ip> --use-remote-sudo
Note
Replace nixosConfiguration with pine-bbb-standard-emmc or
pine-bbb-standard-sd if running from sd-card
- Expand partition on first boot when built for SD card
- Look into
disk-by/partition-labelissue