-
Notifications
You must be signed in to change notification settings - Fork 5
instantNIX on a Raspberry Pi 4B
con-f-use edited this page Feb 7, 2021
·
5 revisions
You will need the following items:
- Micro SD-Card (though the installation clocked in at <6GB we recommend 16GB for a useful system with some space left to play with)
- Raspberry Pi 4 Model B
- Way for the Pi to connect to the internet
- Way to power your Pi (an USB-C charger is fine)
- Display
- Way to connect your Pi to said display (for most this will be a HDMI to Micro HDMI cable)
- USB keyboard
- Either a separate internet connected computer with a Micro SD-Card reader or an alternative boot device for the Pi
Note: The Pi 4B, as of writing, is not yet officially supported by NixOS. This means this guide might be outdated by the time you read this and you should use the official image. It also means that some of the contents of raspi4.nix
could be outdated and wrong.
- Download the latest Raspberry Pi 4 B image
Make sure it is from a successful build, Hydra builds fail from time to time
curl https://hydra.nixos.org/build/134720986/download/1/nixos-sd-image-21.03pre262561.581232454fd-aarch64-linux.img.zst | unzstd - > nixos-sd-image-21.03pre262561.581232454fd-aarch64-linux.img
- Compare the hash with that from the hydra build web page, to make sure the image integrity was preserved.
sha256 nixos-sd-image-21.03pre262561.581232454fd-aarch64-linux.img # should output: 2f756bc08a5f1e286a82ea4c9a50892f2aa9fd1688be37a85d4e36776569763e in case of ...21.03pre262561.581232454fd-aarch64
- Write the image to an SD-card:
Double-check the output file part (
lsblk # lists the devices connected to your PC, memory cards should start with "mmcblk" sudo dd bs=65536 conv=noerror,sync status=pgrogress if=nixos-sd-image-21.03pre262561.581232454fd-aarch64-linux.img of=/dev/mmcblkX
of=/dev/...
) or you will potentially overwrite entire disks and loose important data. You don't need to resize or partition anything, the image takes care of that. - Insert the card into the Raspberry Pi, connect a screen and keyboard and power on. You should boot into NixOS. From now on all commands are to be run on your Raspi.
- Run
sudo nixos-generate-config
to generate a basic hardware configuration file in/etc/nixos/
- Copy the config file to
/etc/nixos/configuration.nix
and inspect/etc/nixos/hardware-configuration.nix
for afileSystems = { "/" ...
part, that might need to be deleted.You should edit at least the user part (authorized ssh public keys, password hash) of the new configuration. To generate a new password hash, runsudo mv /etc/nixos/configuration.nix /etc/nixos/configuration.nix.generated sudo curl -L https://raw.githubusercontent.com/instantOS/instantNIX/dev/utils/raspi4.nix --output /etc/nixos/configuration.nix sudo nano /etc/hardware-configuration.nix # delete the `fileSystems = { "/" ...` if it as a weird UUID sudo nano /etc/configuration.nix # edit the new configuration
nix-env -i mkpasswd && mkpasswd -m sha-512
. The result can be pasted in thehashedPassword
section. - Switch to the new configuration with
sudo nixos-rebuild switch
. You should now be able to reboot into instantNIX.