Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raspberry Pi 5 support #260754

Open
cor opened this issue Oct 12, 2023 · 69 comments
Open

Raspberry Pi 5 support #260754

cor opened this issue Oct 12, 2023 · 69 comments
Labels
0.kind: question 2.status: wait-for-upstream Waiting for upstream fix (or their other action). 6.topic: hardware

Comments

@cor
Copy link
Contributor

cor commented Oct 12, 2023

Has anyone been able to run NixOS on the newly released Raspberry Pi 5? It's not included yet in the wiki's compatibility matrix.

@samueldr
Copy link
Member

samueldr commented Oct 13, 2023

"NixOS" proper won't see support for the Raspberry Pi 5.

Just like all other ARM platforms, NixOS support depends on the platform's support in upstream mainline projects.

We will not repeat the mistake we did with the Raspberry Pi 4 and adding bespoke support for a proprietary ecosystem. It is too much work to support for the resources available to NixOS.

Note that this reply applies to any $BOARD, and not limited to ARM things.

So the roadmap to "NixOS booting trivially on Raspberry Pi 5" is:

  • upstream support in U-Boot
  • upstream support in Linux

Then we can add its U-Boot build to the token pre-baked firmware partition (assuming we still ship it by then) and it should work [just as well as mainline supports it].


An additional side-note: With the super-powers conferred to the end-users of NixOS, nothing stops someone from providing useful configurations, overlays, etc to make it work in the meantime as a workaround. Though as implied, it would be user-supported.

@samueldr samueldr added the 2.status: wait-for-upstream Waiting for upstream fix (or their other action). label Oct 13, 2023
@06kellyjac
Copy link
Member

I think we're all on the same page that it'd be great to have official support but as @samueldr says a lot of work has gone into supporting the Pi (and the oddities of other SOCs).
It'd also probably be less painful to do some of this bespoke work if there was some kind of commitment or timeline from the manufacturers to getting this stuff upstreamed in the end.

https://github.com/NixOS/nixos-hardware/commits/master/raspberry-pi/4
https://github.com/NixOS/nixpkgs/commits/master/pkgs/os-specific/linux/firmware/raspberrypi
https://github.com/NixOS/nixpkgs/commits/master/pkgs/os-specific/linux/raspberrypi-eeprom
https://github.com/NixOS/nixpkgs/commits/master/pkgs/os-specific/linux/kernel/linux-rpi.nix
https://github.com/NixOS/nixpkgs/commits/master/nixos/modules/system/boot/loader/raspberrypi

A nix-community project might be more appropriate this time around so there's a centralized spot to collaborate but it's still distinctly marked unofficial.
I'm not sure if it should be general SOCs, split by architectures, Pis, or just Pi5 focused though 🤷

vision5/riscv support has been going alright without a more central project due to a couple of vocal and active community members + a bit of sponsorship support

@MayNiklas
Copy link
Member

I wasn't able to get the Pi 5 to boot with NixOS.
The Linux kernel received some commits, that should help in the future.

The boot loader shows me the following:

Device-tree file "bcm2712-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.

Wasn't able to get it to boot - no matter what I've tried.

@softerdk
Copy link

softerdk commented Dec 4, 2023

My pi5 needs Nixos :-)

@WizardUli
Copy link

WizardUli commented Dec 11, 2023

I wasn't able to get the Pi 5 to boot with NixOS. The Linux kernel received some commits, that should help in the future.

The boot loader shows me the following:

Device-tree file "bcm2712-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.

Wasn't able to get it to boot - no matter what I've tried.

You need to use patched kernel sources from Raspberry. You also need to use device tree files from Raspberry and merge them using opensource but non-standard dtmerge (unless Pi5 bootloader changed significantly which is also a possibility).

I wholeheartedly support the decision not to deal with these oddities officially and support only boards with all drivers & patches & DTSs in the upstream kernel & having standard EFI!

But it is NOT that hard to get a new embedded system running in Nix. Not at all. I actually found Nix through embedded systems when I was fed up after many years with Buildroot and similar build systems and Nix (but only with (those unstable) Flakes because of very practical reasons!) when used for embedded systems is like a fairy-tale in comparison.

I do plan to get Pi5 running along with a simplified disk image generation (lots of unneeded magic stuff surrounding the current make-ext4-fs.nix and all its wrappers galore) some-when next year.

@ElvishJerricco
Copy link
Contributor

There are actually patches for u-boot for the rpi5, though they're far from complete. I was able to use that to get a very haphazard build of nixos's sd image booting, but it's pretty rough.

@leo60228
Copy link
Member

leo60228 commented Jan 4, 2024

I got things sort of working without U-Boot:
NixOS neofetch on Pi 5
My code is at https://github.com/leo60228/nixpkgs/tree/rpi5, but this isn't really in a state where I'd recommend using it. It's probably best to wait until U-Boot support is in a usable state.

@leo60228
Copy link
Member

leo60228 commented Jan 4, 2024

NixOS seems to "just work" with https://github.com/worproject/rpi5-uefi, though device support is currently very limited (Ethernet and fan control are the most painful omissions for headless/server use). For some applications, it might already be enough, though.

Compared to U-Boot, this has the major benefit of being able to just use the standard aarch64 installer with a mainline kernel. If device tree support gets added to EDK2, it'd hopefully be possible to switch to the vendor kernel post-installation for more complete hardware support, without needing a special Pi-specific installer image.

Using the vendor kernel with ACPI might be superior in some senses, but this seems fragile, and I really doubt it'd be considered a supported usecase by the driver developers.

@leo60228
Copy link
Member

leo60228 commented Jan 5, 2024

There are a number of reasons this is a bad idea, but installing NixOS using EDK2 and then adding this to the configuration seems to mostly work:

{
  boot.kernelPackages = (import <nixpkgs-rpi5> {}).linuxPackages_rpi5;
  boot.kernelParams = [ "dtb=\\bcm2712-rpi-5-b.dtb" ];
}

@leo60228
Copy link
Member

leo60228 commented Jan 5, 2024

rpi5-uefi 0.2 adds device tree support, which seems to work perfectly when using the vendor kernel with UEFI! I'll try to make a flake with the Pi 5 kernel and start writing a wiki page.

@leo60228
Copy link
Member

leo60228 commented Jan 5, 2024

I've created a preliminary wiki page with basic installation instructions: https://nixos.wiki/wiki/NixOS_on_ARM/Raspberry_Pi_5

@tkerber
Copy link
Member

tkerber commented Jan 18, 2024

The above wiki entry is very helpful for getting the PI to boot, but I've had no success booting to X11 or Wayland. While the wiki does list "Graphics drivers are not yet available in NixOS.", this surprises me, given that mesa 23.3.0 has since made it into nixpkgs, which I believe has the drivers for the pi's GPU.

If anyone gets graphics working, I'd be curious how :)

@nbdd0121
Copy link
Contributor

@leo60228 I tested rpi5-uefi and you flake, and it seems to be working perfectly! Thanks a lot!

I think the only addition in your flake compared to the upstream linux-rpi vendor kernel is the added defconfig line? If so, would you mind submitting a PR so we can just use linuxKernel.kernels.linux_rpi5 (and hopefully be able to use the binary cache)?

@leo60228
Copy link
Member

I think the only addition in your flake compared to the upstream linux-rpi vendor kernel is the added defconfig line? If so, would you mind submitting a PR so we can just use linuxKernel.kernels.linux_rpi5 (and hopefully be able to use the binary cache)?

I made that flake before the recent PR updating linux-rpi in Nixpkgs, but this is more or less correct. I was waiting on that PR to be merged before submitting one adding linux_rpi5, I'll try to do that once I'm home tonight if I remember.

@ElvishJerricco
Copy link
Contributor

Realistically, we should be able to build one rpi kernel for rpi 3, 4, and 5. That's how raspbian works. We can even do the same with u-boot, using u-boot's rpi_arm64_defconfig.

@nbdd0121
Copy link
Contributor

Apparently according to https://www.raspberrypi.com/documentation/computers/linux_kernel.html, rpi5 uses a different config so it uses 16K page instead of 4K.

@ElvishJerricco
Copy link
Contributor

@nbdd0121 hm, seems like it's a tradeoff of performance vs compatibility. For performance, use the rpi5 specific kernel, for compatibility, use the rpi4 one.

@RyanGibb
Copy link
Contributor

I've hacked around and got the installation medium booting from the EFI. Does anyone know if it's possible to install NixOS to the same medium (SD card) as the EFI? The EDK2 docs are elusive.

@arti5an
Copy link
Member

arti5an commented Jan 24, 2024

I used the wiki page @leo60228 created as somewhat of a guide (thanks - you're a star), got my Pi 5 to boot the UEFI from SD, imaged the aarch64 minimal installer to a USB drive and booted that. From there I was indeed able to install to the SD, with NixOS's boot images sharing the same partition as the UEFI loader. Whether that's a good or bad idea I don't know. Not sure what would happen if you somehow booted the installer from the same SD however. I suspect having the partition(s) mounted might hinder those efforts. 🤷

A few notes from my experience which may be useful:

  1. I have the official cooling heatsink/fan, and after booting the UEFI image it locked on full speed. The CPU also runs at full speed with the standard kernel, so that first install and kernel build get a little noisy.

  2. This one's easily avoided, but may be what allowed me to use the same partition for boot... I neglected to repartition my SD to GPT (I started with the official Pi image and partitions on there). I simply reformatted the existing partitions to save a step (or so I thought). I later found out it was an MBR partition table when I tried to use systemd-boot via configuration.nix. I resorted to disabling that and using grub as it was a little too late in the day to start again. Rookie mistake!

  3. Finally, probably through lack of experience at this level and limited free time, I haven't managed to get a desktop environment to boot once it's installed and the vendor kernel applied. I suspect that probably just needs some config.txt modifications, so if I crack that particular case I'll share my findings and/or submit a PR. I plan to investigate how this was pulled off (and works so beautifully I might add) on my Pi 4. I doubt I'll get there before someone with superior Nix-fu to my own however. 😄

That aforementioned partition table issue I do plan to rectify in due course, but currently that kernel build from @leo60228 is unfortunately an overnight job for my Pi, so I don't have the free time to keep retrying at the moment. If I do get around to trying that then I'll report my findings, good or bad, unless someone beats me to it.

@RyanGibb
Copy link
Contributor

That aforementioned partition table issue I do plan to rectify in due course, but currently that kernel build from @leo60228 is unfortunately an overnight job for my Pi

Try:

$ sudo gdisk /dev/<path>

Then w to confirm converting the mbr table to a gpt table.

@RyanGibb
Copy link
Contributor

RyanGibb commented Jan 24, 2024

I'm another who has got it working with rpi5-uefi and @leo60228's flake!

The debian UEFI docs where useful in understanding you can extract the bootloader to the same partition as the EFI implementation.

For posterity, here are some step-by-step instructions.

Format your SD-card, create filesystems, and extract the Raspberry Pi UEFI EDK2 implementation to the boot entry:

sd-card=/dev/sda
sudo parted $sd-card mklabel gpt
sudo parted $sd-card -- mkpart ESP fat32 1MB 512MB
sudo parted $sd-card -- mkpart primary 512MiB 100%
sudo mkfs.fat -F 32 -n BOOT ${sd-card}1
sudo mkfs.ext4 -L NIXOS ${sd-card}2
curl https://github.com/worproject/rpi5-uefi/releases/download/v0.2/RPi5_UEFI_Release_v0.2.zip --output ./RPi5_UEFI_Release_v0.2.zip
sudo mount ${sd-card}1 /mnt/
sudo unzip ./RPi5_UEFI_Release_v0.2.zip -d /mnt/

Flash NixOS arm64 minimial installer to USB drive:

usb-drive=/dev/sdb
curl https://channels.nixos.org/nixos-23.11/latest-nixos-minimal-aarch64-linux.iso --output ./latest-nixos-minimal-aarch64-linux.iso
sudo dd bs=4M if=./latest-nixos-minimal-aarch64-linux.iso of=${usb-drive} conv=fsync oflag=direct status=progress

On the Pi now, boot into the installer and network it over WiFi (as Ethernet doesn't work).

sudo systemctl start wpa_supplicant
wpa_cli
> add_network
0
> set_network 0 ssid "myhomenetwork"
OK
> set_network 0 psk "mypassword"
OK
> set_network 0 key_mgmt WPA-PSK
OK
> enable_network 0
OK

Mount the SD-card:

sd-card=/dev/mmcblk0p
sudo mount ${sd-card}p2 /mnt
sudo mkdir /mnt/boot
sudo mount ${sd-card}p1 /mnt/boot

Generate and edit your config with nixos-generate-config --root /mnt.

You'll want to set:

  boot.loader.grub.device = "nodev";
  boot.loader.grub.efiSupport = true;

To install the bootloader to /EFI/ on the boot partition.

And to add the vendor kernel with e.g.:

  boot.kernelPackages = (import (builtins.fetchTarball https://gitlab.com/vriska/nix-rpi5/-/archive/main.tar.gz)).legacyPackages.aarch64-linux.linuxPackages_rpi5;

Then you can install NixOS with

sudo nixos-install

Then to boot the vendor kernel, in the UEFI settings switch from ACPI to Device Tree in

Device Manager
-> Raspberry Pi Configuration
-> ACPI / Device Tree
-> System Table Mode

I also removed force_turbo=1 from /boot/config.txt as suggested.

NB I couldn't get NixOS to boot automatically even adding the /EFI/ file with:

Boot Maintenance Manager
-> Boot Options
-> Add Boot Option
-> BOOT[VenHw(<uuid>)/SD(0x0)/HD(1,GPT,<uuid>)]
-> <EFI>
-> <NixOS-boot>
-> grubaa64.efi

So I need to manually boot from file:

Boot Maintenance Manager
-> Boot Options
-> Boot From File
-> BOOT[VenHw(<uuid>)/SD(0x0)/HD(1,GPT,<uuid>)]
-> <EFI>
-> <NixOS-boot>
-> grubaa64.efi

Perhaps this is related to using a GPT partition table.

I also tried to a cross-compiled installation straight to the SD card from an x86_64 machine which failed due to grub's perl dependency not building.

sudo nixos-install --root /mnt/sd/ --flake ~/projects/nixos-rat#rat-install
[sudo] password for ryan:
warning: Git tree '/home/ryan/projects/nixos-rat' is dirty
building the flake in git+file:///home/ryan/projects/nixos-rat...
warning: Git tree '/home/ryan/projects/nixos-rat' is dirty
error: build of '/nix/store/vn4d9m24vfx4xirvc7xa5i8qzyi43mai-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu.drv' on 'ssh-ng://rtg24@daintree.cl.cam.ac.uk' failed: builder for '/nix/store/vn4d9m24vfx4xirvc7xa5i8qzyi43mai-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu.drv' failed with exit code 2;
       last 10 log lines:
       > Installing /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/share/man/man3/XML::SAX::PurePerl.3
       > Installing /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/share/man/man3/XML::SAX::Intro.3
       > Installing /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/share/man/man3/XML::SAX.3
       > Installing /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/share/man/man3/XML::SAX::DocumentLocator.3
       > Installing /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/share/man/man3/XML::SAX::PurePerl::Reader.3
       > Installing /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/share/man/man3/XML::SAX::ParserFactory.3
       > Appending installation info to /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/lib/perl5/5.38.0/aarch64-linux/perllocal.pod
       > Can't locate XML/SAX.pm in @INC (you may need to install the XML::SAX module) (@INC entries checked: /nix/store/886v5dis8c552ahqdp169svcynh0rfxr-perl-aarch64-unknown-linux-gnu-5.38.0-mini/lib/perl5/cross_perl/5.38.0 /nix/store/3iafhgzzbv7n2bx1vj2ffb812mqn54s5-perl-aarch64-unknown-linux-gnu-5.38.0/lib/perl5/5.38.0 /nix/store/3iafhgzzbv7n2bx1vj2ffb812mqn54s5-perl-aarch64-unknown-linux-gnu-5.38.0/lib/perl5/5.38.0/aarch64-linux /nix/store/3iafhgzzbv7n2bx1vj2ffb812mqn54s5-perl-aarch64-unknown-linux-gnu-5.38.0/lib/perl5/site_perl/5.38.0 /nix/store/3iafhgzzbv7n2bx1vj2ffb812mqn54s5-perl-aarch64-unknown-linux-gnu-5.38.0/lib/perl5/site_perl/5.38.0/aarch64-linux /nix/store/5rafz6z3p427rlpyz575xg089igz4fzx-perl5.38.0-XML-NamespaceSupport-1.12-aarch64-unknown-linux-gnu/lib/perl5/site_perl/5.38.0 /nix/store/5rafz6z3p427rlpyz575xg089igz4fzx-perl5.38.0-XML-NamespaceSupport-1.12-aarch64-unknown-linux-gnu/lib/perl5/site_perl/5.38.0/aarch64-linux /nix/store/qhdfvfqy4vy7p4w4kxr3fh0mb9xmvswv-perl5.38.0-XML-SAX-Base-1.09-aarch64-unknown-linux-gnu/lib/perl5/site_perl/5.38.0 /nix/store/qhdfvfqy4vy7p4w4kxr3fh0mb9xmvswv-perl5.38.0-XML-SAX-Base-1.09-aarch64-unknown-linux-gnu/lib/perl5/site_perl/5.38.0/aarch64-linux /nix/store/p5fzs2zh9faxdnqpzxfmcv17kai0waal-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu/lib/perl5/site_perl .).
       > BEGIN failed--compilation aborted.
       > make: *** [Makefile:743: install_sax_pureperl] Error 2
       For full logs, run 'nix log /nix/store/vn4d9m24vfx4xirvc7xa5i8qzyi43mai-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu.drv'.
error: builder for '/nix/store/vn4d9m24vfx4xirvc7xa5i8qzyi43mai-perl5.38.0-XML-SAX-1.02-aarch64-unknown-linux-gnu.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/kpz47x1vwg4k9byid1fb7rb4wa1rf3ck-perl-aarch64-unknown-linux-gnu-5.38.0-env.drv' failed to build
error: 1 dependencies of derivation '/nix/store/mba97l6yh5f7rx9xrc55mf5csvg51m3s-install-grub.sh.drv' failed to build
error: 1 dependencies of derivation '/nix/store/c5d5z8hrgh8x7w0nfklyvvhf48jc8fzb-nixos-system-rat-23.11.20240115.b8dd8be.drv' failed to build

Perhaps cross-compiling with QEMU would work.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/install-nixos-on-raspberry-pi-5/38833/2

@leo60228
Copy link
Member

leo60228 commented Jan 27, 2024

I couldn't get NixOS to boot automatically

I don't think EFI runtime variables are supported (yet?), so you should set boot.loader.efi.canTouchEfiVariables = false; (and boot.loader.grub.efiInstallAsRemovable = true; for GRUB, I think? I'm using systemd-boot).

Finally, probably through lack of experience at this level and limited free time, I haven't managed to get a desktop environment to boot once it's installed and the vendor kernel applied. I suspect that probably just needs some config.txt modifications, so if I crack that particular case I'll share my findings and/or submit a PR.

You need to add dtoverlay=vc4-kms-v3d-pi5 for the GPU driver to work (I've added this to the wiki page). From there, Wayland DEs should work. I wasn't able to get X11 to work, and from what I can tell upstream doesn't support it on this hardware. I had some issues with graphical corruption on KDE that didn't happen on GNOME, but I was going to wait for Plasma 6 before looking in to that further.

@cmacrae
Copy link
Contributor

cmacrae commented Feb 9, 2024

Thanks for all the useful conversation had here and resources put together! I was able to get NixOS installed with relative ease on my Pi 5 yesterday, which has now replaced my previous NixOS Pi 4 as a DHCP, DNS, WireGuard, and nginx server for my network and has been working great, much more performant ✨

I figured I'd share a little bit of my experience here in case it helps others.
For the most part, I followed @RyanGibb's handy overview to get going. The only difference really is that I made sure to set the ESP property on the first partition of the SD card with parted:

parted /dev/mmcblk0 -s set 1 esp on

Then proceeded with the mounting. Generate the config. Edit the config to what should roughly be a minimal working system:

configuration.nix
{ config, lib, pkgs, ... }:

{
  imports = [ ./hardware-configuration.nix ];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = false;

  networking.hostName = "rpi5"; # Define your hostname.
  networking.wireless.iwd = {
    enable = true;
    settings.General.EnableNetworkConfiguration = true;
  };

  time.timeZone = "Europe/London";

  environment.systemPackages = with pkgs; [
    vim
    curl
    git
  ];

  # just for access after install to continue provisioning
  services.openssh.enable = true;
  services.openssh.settings.PermitRootLogin = "yes";

  networking.firewall.enable = false;

  system.stateVersion = "23.11";

}
hardware-configuration.nix
{ config, lib, pkgs, modulesPath, ... }:

{
  imports =
    [
      (modulesPath + "/installer/scan/not-detected.nix")
    ];

  boot.initrd.availableKernelModules = [ "usbhid" "usb_storage" ];
  boot.initrd.kernelModules = [ ];
  boot.kernelModules = [ ];
  boot.kernelPackages = (import (builtins.fetchTarball https://gitlab.com/vriska/nix-rpi5/-/archive/main.tar.gz)).legacyPackages.aarch64-linux.linuxPackages_rpi5;
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    {
      device = "/dev/disk/by-uuid/ecb26648-686e-403c-a415-406ac554653d";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    {
      device = "/dev/disk/by-uuid/0CAE-25FE";
      fsType = "vfat";
    };

  swapDevices = [ ];

  networking.useDHCP = lib.mkDefault true;

  nixpkgs.hostPlatform = lib.mkDefault "aarch64-linux";
}

Made sure to set boot.loader.efi.canTouchEfiVariables = false; and set boot.kernelPackages to use @leo60228's kindly provided flake output.

Before continuing with the install, here's what others may find particularly useful: the Pi is going to take a loooooong time to compile the kernel. If, like me, you happen to be using NixOS on another, more ample aarch64 system (I'm running NixOS with Asahi on an M2 MacBook Air), you can just build your Pi's system closure on that and then copy it to the installer's Nix store:

  1. sshd should be on already for the nixos-installer environment, but if it's not, start it
  2. set a password for the root user (sudo -i to get a root shell)
  3. On your other aarch64 system, make sure you replicate the minimal "bootstrap" config for your Pi. I just defined a nixosConfiguration for my Pi in my flake with the config I laid out above
  4. Build the system closure for the Pi on your more ample system. For me, with rpi5 being the name of the nixosConfiguration in my flake, that looked like:
nix build -L .#nixosConfigurations.rpi5.config.system.build.toplevel

(if you have problems with impurity because of flakes, either pass --impure or include the kernel flake as an input and reference the package that way)

  1. Wait for the build to complete, grab some tea or a coffee ☕
  2. When the build is done, copy the results to the nixos-installer's Nix store:
nix copy -s --to ssh://root@<IP of your running nixos-installer> ./result 
  1. Once the copy completes, you can run nixos-install as usual - all the results have already been built, so it'll only need to do a few more bootstrapping steps and copying things around
  2. Finish the install as usual (set the root password, etc.)
  3. Reboot and follow the steps @RyanGibb illustrated to move off ACPI
  4. Proceed to save settings, remove your installer USB so it's just the SD card left, use the boot manager to try booting that, it'll prompt you to "Reset". Answer 'Y' and soon you'll, hopefully 🤞, be greeted by the systemd boot menu

I appreciate that's a bit of a 🧠 dump, so please feel free to ask for any clarification on the above steps.

One other curiosity I had before I did the install was if ethernet worked once booted to NixOS with the vendor kernel and Device Tree/System Table mode. It wasn't clear to me based on comments/info available if it would. For anyone wondering: it does :)

@miangraham
Copy link
Contributor

Big thanks for the kernel packages and guides.

the Pi is going to take a loooooong time to compile the kernel

For anyone else who's curious, I ran the experiment to put a number on it. Haven't gone through with the installation yet, but building from a Pi 5 4GB running debian on an nvme drive, the result was:

$ nix build -L .#nixosConfigurations.....config.system.build.toplevel
# ...
took 2h9m50s

It's long, but it's not waiting for hydra long. ;)

@leo60228
Copy link
Member

I knew I was forgetting a step when I added it to the wiki, but couldn't think of what it was.... oops.

@malteneuss
Copy link
Contributor

malteneuss commented May 1, 2024

I just found out that U-Boot in its v2024.04 release got basic pi 5 support (e.g. booting from SD but not USB,NVMe):
https://patchwork.ozlabs.org/project/uboot/list/?series=391659&state=%2A&archive=both

Is anyone able to update (or link to the MR) nixpkgs to the new U-boot release? If so, together with NixOS/nixos-hardware#927 (landing in NixOS-hardware soon) we would be quite close to get a convenient Pi 5 setup along the lines of:

# flake.nix
{
  # kernel suitable for pi 5
  inputs.nixos-hardware.url = "github:malteneuss/nixos-hardware/raspberry-pi-5";
  inputs.nixpkgs-unstable.url = "nixpkgs/nixos-unstable";

  outputs =
    inputs@{ self
    , nixos-hardware
    , nixpkgs-unstable
    , ...
    }:

   nixosConfigurations.pi5 = nixpkgs-unstable.lib.nixosSystem {
        modules = [
           my-configuration.nix
           ({ pkgs, modulesPath, ... }: {
              nixpkgs = {
                localSystem = {
                  system = "x86_64-linux";
                };
                crossSystem = { # <--------------cross-compile on Intel/AMD machine. Emulated native compilation with binfmt too slow.
                  system = "aarch64-linux";
                };
              # workaround for breaking linux kernel changes https://github.com/NixOS/nixpkgs/issues/154163#issuecomment-1350599022
               overlays = [   # <-------------------------------
                  (final: super: {
                     makeModulesClosure = x: super.makeModulesClosure (x // { allowMissing = true; });
                   })
               ];
             }; # nixpkgs end
             imports = [
                nixos-hardware.nixosModules.raspberry-pi-5
                "${toString modulesPath}/installer/sd-card/sd-image-aarch64.nix"
             ];
            })
        ];
      };
};

which could then be build into an SD card image using the regular

nix build .\#nixosConfigurations.pi5.config.system.build.sdImage

edit: the new u-boot is already in nixpkgs-unstable:

defaultVersion = "2024.04";

@leo60228
Copy link
Member

leo60228 commented May 1, 2024

Using crossSystem globally is problematic since it means packages can't be fetched from the binary cache. If I didn't have a fast ARM machine available, I'd probably set crossSystem just for the kernel, and build the image using the Pi as an aarch64-linux remote builder (with Nix installed on Raspberry Pi OS).

@malteneuss
Copy link
Contributor

malteneuss commented May 1, 2024

@leo60228 These are two good setup variations that should be documented somewhere, probably on the Wiki page (i would love a setup where i don't need to fiddle around and install Nix on the Pi to build Nix stuff; just generate a ready NixOS image, dd it onto an sd-card or NVMe and be ready to go^^). The global cross-compile wasn't so bad though on an average laptop; maybe even faster than a native build on the Pi.

Since u-boot in nixpkgs has basic pi 5 support, what can we do now to create a "final" sd card image?
My impression is that using something a long the lines of

boot.loader.generic-extlinux-compatible.enable = true;
boot.loader.systemd-boot.enable = false;
boot.loader.efi.canTouchEfiVariables = false;

should be sufficient.

@nvmd
Copy link
Member

nvmd commented May 1, 2024

@leo60228 These are two good setup variations that should be documented somewhere, probably on the Wiki page (i would love a setup where i don't need to fiddle around and install Nix on the Pi to build Nix stuff; just generate a ready NixOS image, dd it onto an sd-card of NVMe and be ready to go^^). The global cross-compile wasn't so bad though on an average laptop; maybe even faster than a native build on the Pi.

Since u-boot in nixpkgs has basic pi 5 support, what can we do now to create a "final" sd card image? My impression is that using something a long the lines of

boot.loader.generic-extlinux-compatible.enable = true;
boot.loader.systemd-boot.enable = false;
boot.loader.efi.canTouchEfiVariables = false;

should be sufficient.

@malteneuss You may have a look at this project: https://github.com/tstat/raspberry-pi-nix.
What it does is essentially generate such sd-image bootable with u-boot or raspberry pi's boot process, also managing config.txt from nix.
It is not ideal, cross-compilation is not covered, for example. Or from an ideology standpoint. But it gets the job done.
U-boot will obviously need to be overridden for RPi5. Raspberry Pi's boot works right out of the box for the 5 if you just want to start with something. IMO for a single-use installation image, Raspberry Pi's boot is acceptable, as you don't have more than a single nixos generation anyway.

Here is for https://github.com/tstat/raspberry-pi-nix/blob/master/sd-image/default.nix if you just want to know how sd-image with uboot is generated.

@malteneuss
Copy link
Contributor

malteneuss commented May 10, 2024

Just wanted to report back that @nvmd suggestion of https://github.com/tstat/raspberry-pi-nix so far has the simplest works-out-of-the-box experience i've seen so far; just use the example there. It seems to package the official firmware and kernels for Pi 5 and works without u-boot, as well as soon with u-boot nix-community/raspberry-pi-nix#13.

However, it can't be cross-compiled (yet), but setting up the Pi as a remote native builder is easier than i thought:

  1. Install the Nix package manager on Pi 5 Debian OS the normal way with sh <(curl -L https://nixos.org/nix/install) --daemon.
  2. setup a ssh connection from your local machine to the Pi, especially adding SetEnv PATH=/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin to the Pi's /etc/ssh/sshd_config file.
  3. add the remote Pi as a nix.buildMachines entry to your local machine and use connection protocol ssh-ng(!).

I've simplified the guide on https://wiki.nixos.org/wiki/Distributed_build a bit on the details for that.

fyi: The whole build for a final, pre-configured NixOS sd card image takes ~3h on the Pi 5 8GB. You can then dd that image onto an SD card or NVMe and boot.

@aflox405
Copy link

Thanks everyone for bootstrapping this, it's awesome and much appreciated work ❤️

I've started following the combined guides of @RyanGibb and @cmacrae , but it seems I got stuck somewhere...
I prepared the SDcard, booted the USB and installed NIxOS (24.05) to the SDcard as suggested.
After rebooting, unplugging the USB drive and switching from AHCI to device tree, the PI boots into systemd-boot, I see the NixOS entry, but after selecting it, I see

EFI stub: Booting Linux Kernel ....
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path
EFI stub: Generating empty DTB
EFI stub: Exiting boot service ...

And then nothing happens. I'd appreciate any pointers 🙏

@jDmacD
Copy link

jDmacD commented Jun 15, 2024

Just wanted to report back that @nvmd suggestion of https://github.com/tstat/raspberry-pi-nix so far has the simplest works-out-of-the-box experience i've seen so far; just use the example there. It seems to package the official firmware and kernels for Pi 5 and works without u-boot, as well as soon with u-boot tstat/raspberry-pi-nix#13.

However, it can't be cross-compiled (yet), but setting up the Pi as a remote native builder is easier than i thought:

1. Install the Nix package manager on Pi 5 Debian OS the normal way with `sh <(curl -L https://nixos.org/nix/install) --daemon`.

2. setup a `ssh` connection from your local machine to the Pi, especially adding `SetEnv PATH=/nix/var/nix/profiles/default/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin` to the Pi's `/etc/ssh/sshd_config` file.

3. add the remote Pi as a `nix.buildMachines` entry to your local machine and use connection protocol `ssh-ng`(!).

I've simplified the guide on https://wiki.nixos.org/wiki/Distributed_build a bit on the details for that.

fyi: The whole build for a final, pre-configured NixOS sd card image takes ~3h on the Pi 5 8GB. You can then dd that image onto an SD card or NVMe and boot.

hetzner has very reasonably priced arm servers. I set one up as a a builder using nixos-anywhere. You can use the lowest tier and scale it up anytime you need to perform a kernel build. Using the 16 core instance it takes about 40 minutes!

@celesrenata
Copy link

celesrenata commented Jun 30, 2024

So, I ran into new problems in 24.05 and the RPi5, for some reason one day, as I rolled up changes, my wifi drivers went poof! No matter what I couldn't get them back. So I decided to try to start my journey to upgrade out of the problem.

I've taken a few stabs at it over the weeks thanks to @leo60228's kernel base. I ended up with this working when married with the following overlay https://github.com/raspberrypi/firmware/tree/f1266637375cd7880946dbaceda871f3f308d901/boot/overlays

We now have access to 6.6.35 main! I noticed that stable 6.6.28 and 6.6.31 do not build for us, however, this does!

You will need to update your kernel packages with.... (https://github.com/celesrenata/nix-flakes/blob/rpi5/nixberry/boot.nix)

kernelPackages = let
        linux_rpi5_pkg = { stdenv, lib, buildPackages, fetchFromGitHub, perl, buildLinux, rpiVersion, ... } @ args:

        let
          # NOTE: raspberrypifw & raspberryPiWirelessFirmware should be updated with this
          modDirVersion = "6.6.35";
          tag = "rpi-6.6.y";
        in
        lib.overrideDerivation (buildLinux (args // {
          version = "${modDirVersion}-${tag}";
          inherit modDirVersion;
        
          src = fetchFromGitHub {
            owner = "raspberrypi";
            repo = "linux";
            rev = "c1432b4bae5b6582f4d32ba381459f33c34d1424";
            hash = "sha256-pzjgCWG9FhMU3LCZnvz5N4jYfaaJQDT6Pv5lD/3zsm4=";
          };
          defconfig = {
            "1" = "bcmrpi_defconfig";
            "2" = "bcm2709_defconfig";
            "3" = if stdenv.hostPlatform.isAarch64 then "bcmrpi3_defconfig" else "bcm2709_defconfig";
            "4" = "bcm2711_defconfig";
            "5" = "bcm2712_defconfig";
          }.${toString rpiVersion};
       
          features = {
            efiBootStub = false;
          } // (args.features or {});
       
         # Left over from a previous struggle and can be deleted
          makeFlags = [
            "CONFIG_CEPH_LIB=n"
            "CONFIG_CEPH_FS=n"
            "CONFIG_CEPH_FSCACHE=n"
            "CONFIG_CEPH_FS_POSIX_ACL=n"
            "CONFIG_EROFS_FS_XATTR=n"
            "CONFIG_EROFS_FS_POSIX_ACL=n"
            "CONFIG_EROFS_FS_SECURITY=n"
            "CONFIG_EROFS_FS_ZIP=n"
            "CONFIG_SND_SOC_SIMPLE_MUX=n"
          ];
          # /Delete
 

          extraMeta = if (rpiVersion < 3) then {
            platforms = with lib.platforms; arm;
            hydraPlatforms = [];
          } else {
            platforms = with lib.platforms; arm ++ aarch64;
            hydraPlatforms = [ "aarch64-linux" ];
          };
        } // (args.argsOverride or {}))) (oldAttrs: {
          postConfigure = ''
            # The v7 defconfig has this set to '-v7' which screws up our modDirVersion.
            sed -i $buildRoot/.config -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
            sed -i $buildRoot/include/config/auto.conf -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/'
          '';
        
          # Make copies of the DTBs named after the upstream names so that U-Boot finds them.
          # This is ugly as heck, but I don't know a better solution so far.
          postFixup = ''
            dtbDir=${if stdenv.isAarch64 then "$out/dtbs/broadcom" else "$out/dtbs"}
            rm $dtbDir/bcm283*.dtb
            copyDTB() {
              cp -v "$dtbDir/$1" "$dtbDir/$2"
            }
          '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv6l-linux"]) ''
            copyDTB bcm2708-rpi-zero-w.dtb bcm2835-rpi-zero.dtb
            copyDTB bcm2708-rpi-zero-w.dtb bcm2835-rpi-zero-w.dtb
            copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-a.dtb
            copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b.dtb
            copyDTB bcm2708-rpi-b.dtb bcm2835-rpi-b-rev2.dtb
            copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-a-plus.dtb
            copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-b-plus.dtb
            copyDTB bcm2708-rpi-b-plus.dtb bcm2835-rpi-zero.dtb
            copyDTB bcm2708-rpi-cm.dtb bcm2835-rpi-cm.dtb
          '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv7l-linux"]) ''
            copyDTB bcm2709-rpi-2-b.dtb bcm2836-rpi-2-b.dtb
          '' + lib.optionalString (lib.elem stdenv.hostPlatform.system ["armv7l-linux" "aarch64-linux"]) ''
            copyDTB bcm2710-rpi-zero-2.dtb bcm2837-rpi-zero-2.dtb
            copyDTB bcm2710-rpi-3-b.dtb bcm2837-rpi-3-b.dtb
            copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-a-plus.dtb
            copyDTB bcm2710-rpi-3-b-plus.dtb bcm2837-rpi-3-b-plus.dtb
            copyDTB bcm2710-rpi-cm3.dtb bcm2837-rpi-cm3.dtb
            copyDTB bcm2711-rpi-4-b.dtb bcm2838-rpi-4-b.dtb
          '';
        } // (args.argsOverride or {}));
      linux_rpi5 = pkgs.callPackage linux_rpi5_pkg{
        kernelPatches = with pkgs.kernelPatches; [
          bridge_stp_helper
          request_key_helper
        ];
        rpiVersion = 5;
      };
    in
      pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_rpi5);

I am currently sitting happily on wifi on Hyprland again on my RPi5.

redyf added a commit to redyf/nixdots that referenced this issue Jul 7, 2024
@redyf redyf closed this as not planned Won't fix, can't repro, duplicate, stale Jul 7, 2024
@koalalorenzo
Copy link

It's very sad to hear that this issue has been closed and not planned :(

I run NixOS successfully on 4 rpi 4, and I have started upgrading to rpi 5 slowly. It's a pity that the interest is not there, and I wish I could help somehow as I know that I am not alone!

I know there are difficulties, practical and philosophical. The user base of these board is massive, and I believe I am not the only one eyeing it! Is this something that will change in the future at some point?

@redyf
Copy link
Member

redyf commented Jul 10, 2024

It's very sad to hear that this issue has been closed and not planned :(

I run NixOS successfully on 4 rpi 4, and I have started upgrading to rpi 5 slowly. It's a pity that the interest is not there, and I wish I could help somehow as I know that I am not alone!

I know there are difficulties, practical and philosophical. The user base of these board is massive, and I believe I am not the only one eyeing it! Is this something that will change in the future at some point?

I meant that I accidentaly referenced this issue link on a PR I did 😅. Thanks to the awesome guides in this issue, I managed to install NixOS on a Raspberry PI 5, it's even running Sway (wayland). I'm really happy with it and appreciate all the hard work you guys did!

@nbdd0121
Copy link
Contributor

What do you mean by accidentally opened the issue? The issue is opened @cor ~9 month ago.

@haras-unicorn
Copy link
Contributor

It's very sad to hear that this issue has been closed and not planned :(
I run NixOS successfully on 4 rpi 4, and I have started upgrading to rpi 5 slowly. It's a pity that the interest is not there, and I wish I could help somehow as I know that I am not alone!
I know there are difficulties, practical and philosophical. The user base of these board is massive, and I believe I am not the only one eyeing it! Is this something that will change in the future at some point?

I meant that I accidentaly referenced this issue link on a PR I did 😅. Thanks to the awesome guides in this issue, I managed to install NixOS on a Raspberry PI 5, it's even running Sway (wayland). I'm really happy with it and appreciate all the hard work you guys did!

just to make sure it is planned then but u referencing it somehow closed it? or am i missing something?

@JonBoyleCoding
Copy link
Contributor

I'm a little confused - prior to @redyf closing as not planned 3 days ago, I believe this issue was still set to being open as I check it regularly? I see no reference to it being closed prior either. So why is it now closed?

@redyf redyf reopened this Jul 10, 2024
@redyf
Copy link
Member

redyf commented Jul 10, 2024

This was a HUGE misunderstanding on my part, I apologize for anyone I affected by closing the issue. The concept of issues just wasn't clear enough for me and I thought I could just clear the reference I did to the commit. I had no clue I could actually close the issue that has been opened by other users. In summary, I'm dumb 😅

@ElvishJerricco
Copy link
Contributor

To be clear: The intention going forward is for board-specific support to be done in https://github.com/NixOS/nixos-hardware. Realistically, this should be an issue on that repo, not nixpkgs. Ideally, the rpi kernels would be moved out of nixpkgs altogether.

redyf added a commit to redyf/nixdots that referenced this issue Jul 17, 2024
@tobiasBora
Copy link
Contributor

tobiasBora commented Aug 29, 2024

So I have a few questions:

First, has anyone tried https://github.com/nix-community/raspberry-pi-nix with the rpi5 kernel that is now in nixpkgs and built by hydra? NixOS/nixos-hardware#927 If it works, does it mean that I don't need to rely on cachix anymore?

Then, the wiki mentions that the recommended option is rather to use EDK2 (that seems to default to ACPI mode) + the rpi5 kernel that is in nixpkgs. But my understanding (shared by @K900 in a matrix discussion) is that this solution cannot work since the rpi5 kernel expect devices to be served in a device tree mode… So is the wiki missing a step to enable DT mode here?

Finally, I find it quite hard to know which option to choose from in the wiki, can one compare them in term of:

  1. hardware support
  2. build time
  3. active support (I guess it is better to limit external dependencies that may be unmaintained)

Pinging @malteneuss @leo60228 since it seems like you contributed to the wiki.

@malteneuss
Copy link
Contributor

Unfortunately, i can't remember in what setup EDK2 worked and i no longer own a Pi 5 as it required more tinkering than i have time for. I had the least issues with what is now https://github.com/nix-community/raspberry-pi-nix so you might start with that until a solution to the device tree problem is found.

@leo60228
Copy link
Member

So is the wiki missing a step to enable DT mode here?

@tobiasBora This is covered in the wiki. To my knowledge, the steps in the Alternative board-specific installation notes section are still accurate, though should likely be updated to refer to nixos-hardware instead of my flake.

The "Setting up a generic UEFI NixOS" section was not written by me, and does seem to contain some notable omissions. I think it should probably be unified with the latter section.

@tobiasBora
Copy link
Contributor

@leo60228 Yeah, the steps in https://wiki.nixos.org/wiki/NixOS_on_ARM/Raspberry_Pi_5#Alternative_board-specific_installation_notes are not the ones that I was having issues with… but why do you say that they should be updated with nixos-hardware? Can't we simply use the kernel rpi5 that is now in nixpkgs? Or is this kernel different from the official rpi5 kernel?

Regarding the Setting up a generic UEFI NixOS, the main difference to me with your section is that it does not mention that one must enable DT… hence it seems like this uses ACPI mode, in which case how can this even have a chance to work with the rpi5 kernel that expects DT? Or do you mean that the upstream EDK2 readme mentions somewhere If you're running the RPi downstream kernel, enabling Device Tree instead of ACPI will provide better hardware support. , and the wiki expects the user to follow this recommendation?

But yeah, the wiki page is getting a bit messy now ^^

I had the least issues with what is now https://github.com/nix-community/raspberry-pi-nix so you might start with that until a solution to the device tree problem is found.

Yeah, this worked flawlessly, with cache provided by cachix. For reference I added in my configuration.nix

  boot.binfmt.emulatedSystems = [ "aarch64-linux" ];
  nix = {
    settings = {
      # Enable flakes and new 'nix' command
      experimental-features = "nix-command flakes";
      # Add binary cache
      trusted-substituters = [ "https://nix-community.cachix.org" ];
      trusted-public-keys = [
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
      ];
    };
  };

to enable flake and cachix and emulate compilation on aarch64, then I created a flake.nix containing:

{
  description = "raspberry-pi-nix example";
  nixConfig = {
    # Only during the first build, otherwise I don't want to allow such a binary cache
    extra-substituters = [ "https://nix-community.cachix.org" ];
    extra-trusted-public-keys = [
      "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
    ];
  };
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
    raspberry-pi-nix.url = "github:nix-community/raspberry-pi-nix";
  };

  outputs = { self, nixpkgs, raspberry-pi-nix }:
    let
      inherit (nixpkgs.lib) nixosSystem;
      basic-config = { pkgs, lib, ... }: {
        # bcm2711 for rpi 3, 3+, 4, zero 2 w
        # bcm2712 for rpi 5
        # See the docs at:
        # https://www.raspberrypi.com/documentation/computers/linux_kernel.html#native-build-configuration
        raspberry-pi-nix.board = "bcm2712";
        time.timeZone = "Europe/Paris";
        users.users.root = {
          initialPassword = "some password to change";
          openssh.authorizedKeys.keys = [
            "some ssh key"
          ];          
        };
          # Define a user account. Don't forget to set a password with ‘passwd’.
        users.users.me = {
          isNormalUser = true;
          extraGroups = [ "wheel" ]; # Enable ‘sudo’ for the user.
          initialPassword = "my initial password to change";
          openssh.authorizedKeys.keys = [
            "my ssh key to login directly via ssh"
          ];
        };

        networking = {
          hostName = "myrpi5";
          #useDHCP = false;
          #interfaces = { wlan0.useDHCP = true; };
        };
        environment.systemPackages = with pkgs; [
          emacs
          git
          wget
          bluez
          bluez-tools
        ];
        services.openssh = {
          enable = true;
        };
        hardware = {
          bluetooth.enable = true;
         # TODO: check if needed
          # raspberry-pi = {
          #   config = {
          #     all = {
          #       base-dt-params = {
          #         # enable autoprobing of bluetooth driver
          #         # https://github.com/raspberrypi/linux/blob/c8c99191e1419062ac8b668956d19e788865912a/arch/arm/boot/dts/overlays/README#L222-L224
          #         krnbt = {
          #           enable = true;
          #           value = "on";
          #         };
          #       };
          #     };
          #   };
          # };
        };
        system.stateVersion = "23.11";
      };

    in
      {
        nixosConfigurations = {
          myrpi5 = nixosSystem {
            system = "aarch64-linux";
            modules = [ raspberry-pi-nix.nixosModules.raspberry-pi basic-config ];
          };
        };
      };
}

basically copy/pasted from the readme with a few additions to add ssh keys (I have no HDMI monitor hence I want to be able to connect directly) and build it with:

$ nix build '.#nixosConfigurations.myrpi5.config.system.build.sdImage'

Then just burn on the SD card:

$ sudo su
# zstdcat -v result/sd-image/nixos-sd-image-23.11.20240709.205fd42-aarch64-linux.img.zst > /dev/mmcblk0

and finally just boot the raspberry pi, I did it with ethernet plugged (no monitor), and after a bit of nmap or check the internet box to get the raspberry pi IP, I could just connect via ssh directly. Great, now I need to check hardware support!

@leo60228
Copy link
Member

Can't we simply use the kernel rpi5 that is now in nixpkgs?

There isn't one? If you mean linux_rpi4, that has a different page size which results in worse performance.

@tobiasBora
Copy link
Contributor

I was refering to this pr NixOS/nixos-hardware#927 but do you mean this is rpi4 + some tweaks and not rpi5 itself?

@leo60228
Copy link
Member

leo60228 commented Sep 1, 2024

nixos-hardware isn't part of Nixpkgs.

@tobiasBora
Copy link
Contributor

Oh stupid me… thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: question 2.status: wait-for-upstream Waiting for upstream fix (or their other action). 6.topic: hardware
Projects
None yet
Development

No branches or pull requests