This repository shows how to install NixOS on a Raspberry Pi 5 using a minimal configuration for the nixos-raspberrypi flake configuration by nvmd.
My flake.nix comes from nixos-raspberrypi-demo with modifications for simplicity.
I don't know what I'm doing here and writing it up clearly is a way for me to learn.
- nix with flakes and cross-compilation enabled - put this in
/etc/nix/nix.conf
:sandbox = false extra-platforms = aarch64-linux experimental-features = nix-command flakes
- emulated execution in your OS (e.g. install qemu-user-static on Ubuntu)
- zstd (you can run
nix-shell -p zstd
for example) - Raspberry Pi Imager
- 8GB+ microSD card
nix build .#installerImages
zstd -d result/sd-image/nixos-installer-rpi5-kernelboot.img.zst -o nixos-installer-rpi5-kernelboot.img
- Load file in Raspberry Pi Imager
- (Why can't we configure config.txt settings here?)
- Write image to microSD card
- Insert card into Raspberry Pi 5 and boot
- For WiFi, run
iwctl
, thenstation wlan0 connect <networkname>
where<networkname>
is the name of your wireless network. - Exit
iwct
. - Set a root password with
passwd
. - Log back out to see the IP address.
- Make sure you can connect with
ssh root@<ip>
.
- Clone this repository.
- Copy
private_template.nix
toprivate.nix
and edit with your private user configuration. - Run these weird commands to make flakes work without having to add private.nix (!!!):
git add --intent-to-add private.nix git update-index --assume-unchanged private.nix
- Edit config as desired.
nixos-rebuild switch --flake .#rpi5 --target-host root@<ip>
- Enter your root password twice.
- When it says "Done" you can reboot and everything will be configured as specified.
Note: you can also run
nix build .#nixosConfigurations.rpi5.config.system.build.toplevel
to build the system as a result
link. This might be useful, for
example, to prevent it from getting garbage collected between builds.
- Desktop environments - I can't figure out how to get these to build now.