Waiting for device /dev/disk/by-label/NIXOS_SD to appear

I have now successfully installed nixos on my pi. Here is what I did:
(some of these steps may not be necessary)

  1. install raspberry pi os (I installed the 2021-01-11 release)
  2. upgrade the system (sudo apt update and sudo apt upgrade)
  3. run rpi-eeprom-update -d -a
  4. 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
  5. remove the sd card from the raspberry pi
  6. flash a usb stick with the temporary nixos arm image from hydra
  7. insert the usb stick into the pi and wait for nixos to boot
  8. insert the sd card into the pi
  9. 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
  10. run sudo nixos-generate-hardware-config --root /mnt
  11. delete all default contents from /etc/nixos/configuration.nix
  12. copy the relevant parts from the config file posted to the wiki (see below)
  13. add the unstable nixpkgs channel
    • nix-channel --add https://nixos.org/channels/nixos-unstable nixpkgs
    • nix-channel --update
  14. run sudo nixos-install
  15. reboot
  16. profit
  17. 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.

2 Likes