I have now successfully installed nixos on my pi. Here is what I did:
(some of these steps may not be necessary)
- install raspberry pi os (I installed the 2021-01-11 release)
- upgrade the system (
sudo apt updateandsudo apt upgrade) - run
rpi-eeprom-update -d -a - Run
sudo raspi-config- goto
advanced/boot-configuration - select the option which boots from usb first and from sd if no usb stick was found
- save changes and reboot
- goto
- remove the sd card from the raspberry pi
- flash a usb stick with the temporary nixos arm image from hydra
- insert the usb stick into the pi and wait for nixos to boot
- insert the sd card into the pi
- format the sd card according to the manual for efi and use gpt
- I created 3 partitions, all labeled accordingly
- 512mb efi system partition with fat32 fs mounted to /boot
- 4gb swap partition
- linux partition with ext4 for the remaining space
- I created 3 partitions, all labeled accordingly
- run
sudo nixos-generate-hardware-config--root /mnt - delete all default contents from
/etc/nixos/configuration.nix - copy the relevant parts from the config file posted to the wiki (see below)
- add the unstable nixpkgs channel
nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgsnix-channel --update
- run
sudo nixos-install - reboot
- profit
- re-add the unstable nixpkgs channel (for future rebuilds)
My configuration file looks like this:
{ config, pkgs, ... }:
{
imports = [
./hardware-configuration.nix
];
boot = {
kernelPackages = pkgs.linuxPackages_rpi4;
tmpOnTmpfs = true;
initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
# ttyAMA0 is the serial console broken out to the GPIO
kernelParams = [
"8250.nr_uarts=1"
"console=ttyAMA0,115200"
"console=tty1"
# Some gui programs need this
"cma=128M"
];
loader = {
raspberryPi = {
enable = true;
version = 4;
};
grub.enable = false;
generic-extlinux-compatible.enable = false;
};
};
hardware.enableRedistributableFirmware = true;
powerManagement.cpuFreqGovernor = "ondemand";
networking = {
hostName = "nixpi";
interfaces = {
eth0.useDHCP = true;
};
firewall = {
enable = true;
};
};
nixpkgs.config = {
allowUnfree = true;
};
users.users = {
root = {
password = "changeme";
};
nixos = {
isNormalUser = true;
password = "changeme";
extraGroups = [ "wheel" ];
};
};
services = {
openssh = {
enable = true;
};
};
system.stateVersion = "21.03";
}
I hope this is helpful.