A convenient way to create custom Raspberry Pi NixOS SD images.
So far this has been tested to work with Docker Desktop for Mac and also Docker on Linux.
-
Install QEMU into the host machine:
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
-
Clone this repo.
-
Configure
nixos-rpi-sd-image/sd-image.nix
andnixos-rpi-sd-image/configuration.nix
with your own settings.
-
Use
docker-compose
to mountoutput
and run the container:docker-compose up
-
Check the
output
directory for the.img
file.
-
Burn the
.img
file inoutput
to an SD card with your preferred method. -
Insert the SD card into the Raspberry Pi and wait for it to boot.
-
Wait for NixOS to rebuild and switch (this may take a long time) or SSH into the Raspberry Pi, then run the following command to monitor progress:
journalctl -f -u sd-image-init.service
-
Enjoy!
This was possible mostly in part because of the blog posts and code of
@Robertof, but also the contributors to nixos-generators
and the wiki for
NixOS on ARM.
NixOS on ARM > Building your own image > Compiling through QEMU
NixOS on a Raspberry Pi: creating a custom SD image with OpenSSH out of the box by @Robertof