Since a friend and former colleague told me they’re finally switching to NixOS for their Raspberry Pi fleet, I thought I’d polish up this flake I had for building SD cards and deploying via deploy-rs. A lot has changed since I did that in 2024: nixos-generators has been deprecated in favor of nixos-rebuild build-image, there is apparently a community flake, nvmd/nixos-raspberrypi, for dealing with Pi 5 support, cross-compilation is always “fun.” (it’s not.)
I can cross-compile an SD-card image in about 12 minutes.
Really, the community flake is where the gold is buried.
My contribution is a simple, self-contained flake that assumes the reader isn’t a Nix expert.
Thanks for your example. It helped me to clarify a few things, especially around –accept-flake-config. My RPi4 NixOS config broke after a recent nixpkgs update and I’m trying to bring it back to work. Unfortunately, I’m still seeing linux_rpi-bcm2711-6.12.47-stable_20250916 being built despite some other 8 derivations being fetched from https://nixos-raspberrypi.cachix.org. Really disappointed by nixpkgs maintainers to just drop RPi support without a clear migration path
Have you tried PXE booting an RPi 5? It might be faster and simpler to have a NixOS bootstrap image that can be cached or built quickly, and then build the final system on the RPi to avoid cross-compiling.
I have wanted to run NixOS on my RPi 5 for a while, but as you said, the cross-compilation stuff is a bit of a hassle. Thank you for the write-up.