Skip to content

instantNIX on a Raspberry Pi 4B

con-f-use edited this page Feb 7, 2021 · 5 revisions

Install instantNIX from scratch on a Raspberry Pi 4 Model B


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.

  1. Download the latest Raspberry Pi 4 B image Make sure it is from a successful build, Hydra builds fail from time to time
    curl | 
        unzstd - > nixos-sd-image-21.03pre262561.581232454fd-aarch64-linux.img
  2. 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
  3. Write the image to an SD-card:
    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
    Double-check the output file part (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.
  4. 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.
  5. Run sudo nixos-generate-config to generate a basic hardware configuration file in /etc/nixos/
  6. Copy the config file to /etc/nixos/configuration.nix and inspect /etc/nixos/hardware-configuration.nix for a fileSystems = { "/" ... part, that might need to be deleted.
    sudo mv /etc/nixos/configuration.nix /etc/nixos/configuration.nix.generated
    sudo curl -L --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
    You should edit at least the user part (authorized ssh public keys, password hash) of the new configuration. To generate a new password hash, run nix-env -i mkpasswd && mkpasswd -m sha-512. The result can be pasted in the hashedPassword section.
  7. Switch to the new configuration with sudo nixos-rebuild switch. You should now be able to reboot into instantNIX.

Screen Shots (Literally)

instantwm raspberry pi

wallpaper raspberry pi