Install NixOS on Raspberry Pi 5

I’m trying to install NixOS on my Raspberry Pi 5, but it’s not booting.

Raspbian and others works fine, but it can’t seem to properly boot NixOS and show below error.

Device-tree file "bem2712-rpi-5-b.dtb" not found.

The installed operating system (OS) does not indicate support for Raspberry Pi 5 Update the OS or set os_check=0 in config.txt to skip this check.

I downloaded the latest Aarch64 release from Hydra and tried building a image with custom kernelPackages mentioned nixwiki but no luck.

{ pkgs, lib, ... }: {
  imports = [
    <nixpkgs/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix>
  ];

  # Fix missing modules
  # https://github.com/NixOS/nixpkgs/issues/154163
  nixpkgs.overlays = [
    (final: super: {
      makeModulesClosure = x:
        super.makeModulesClosure (x // { allowMissing = true; });
    })
  ];

  boot = {
    kernelPackages = (import (builtins.fetchTarball
      "https://gitlab.com/vriska/nix-rpi5/-/archive/main.tar.gz")).legacyPackages.aarch64-linux.linuxPackages_rpi5;
    kernelParams =
      [ "8250.nr_uarts=1" "console=ttyAMA0,115200" "console=tty1" "cma=128M" ];
  };

  # WiFi
  hardware = {
    enableRedistributableFirmware = true;
    firmware = [ pkgs.wireless-regdb ];
  };
  # user account.
  users.users.vijay = {
    isNormalUser = true;
    description = "Vijayakumar Ravi";
    extraGroups = [ "networkmanager" "wheel" "docker" ];
    openssh.authorizedKeys.keys = [
      "ssh-ed25519 AAAAC3NzaC......."
    ];
  };

  services.openssh = {
    enable = true;
    settings.PermitRootLogin = "yes";
  };

  sdImage.compressImage = false;
  system.stateVersion = "24.05";
}

Any help ?

RPi 5 is currently not supported by NixOS. It is possible to get it working, but it’s not available in nixpkgs. See the thread on github: Raspberry Pi 5 support · Issue #260754 · NixOS/nixpkgs · GitHub