NixOS 26.05 raspberry pi 4 kernel cache missing?

After upgrade from 25.11 to 26.05, no matter I use

kernelPackages = pkgs.linuxKernel.packages.linux_rpi4;

from nixpkgs or

inputs.nixos-hardware.nixosModules.raspberry-pi-4

from nixos-hardware, the kernel linux-rpi-6.12.75-1+rpt have to compile itself, and now it is over 12 hours and still going…

Am I doing something wrong? It did not happen in the previous release such as 25.11 and 25.05.

1 Like

No, you are not. There is no cache available. I just recompiled the other day on an x86 machine. It took a bit over 12 hours.

When I have time I will try to check if a mainline kernel does the job for me. Some people seem to be using it:

How can I build it in a x86_64 machine? IIRC rpi 4 is aarch64.

You need to enable emulation on the x86 host:

boot.binfmt.emulatedSystems = ["aarch64-linux"];

Then you can run:

nixos-rebuild switch --build-host <IP of x86 system>

If you want you can also do the evaluation on the x86 machine then you can run. Depending on whether you use flakes or not you need to add the system you want to deploy:

nixos-rebuild switch --build-host <IP of x86 system> --target-host <IP of RPI>
1 Like

Thanks for your tip!
But why is this merged PR not functioning to make cache of the kernels?

I think it has been decided to not build downstream kernels on hydra anymore. Can’t find any link for the statement though.

@phaeseeKe5Ee that PR adds the repo-side config, but hydra itself is not pointing at the hardware repo yet. For more info and tracking see the following:

In more promising news, I just removed the kernelPackages = pkgs.linuxKernel.packages.linux_rpi4; line from my rpi4 over the weekend and everything is working just fine, but I am also only using the built-in ethernet+usb, so if you use any hardware features (e.g. hats) then ymmv.

1 Like

Also see Compiling rpi4 kernel in on x86_64 nixos-hardware slow - #10 by penguin_brian

Depending on what your use case is, you might not need the linux_rpi4 vendor kernel. A standard kernel may work.

In my case I need to use the DSI based touch 7” display on a number of my devices. Which I believe does require the vendor kernel.

But yes, otherwise would be using the standard kernel. Switched a headless RPI4 to the standard kernel, no problems so far.

Since building with emulation can be quite slow I went a different route by cross compiling the kernel:

  1. Setup my x86_64 machine as a remote builder (wiki entry, actual config here)
  2. Cross compile the kernel provided by nixos-hardware on the remote builder (actual config here)

The actual build only took around 30 minutes on my (pretty powerful, I would say) machine and the result runs like normal.

The drawback of this approach is that Nix distinguishes between native and cross compiled packages, which means that cross compiling everything (not just the kernel) will result in many cache misses.

1 Like

Just tested the standard kernel and my rpi4 failed to boot up. Maybe caused by my Argon case.

My box which I switched to standard kernel also had an argon case. Only issue I had was the fan stopped working with argononed from nixos 25.11, so I had to switch to argononed from unstable (this was before 26.05 was released which also works fine).

1 Like

On 2nd thoughts just noticed that rpi4 in the argon case now has fan on continuously. Suspect the switch to mainline kernel did this. Haven’t had a chance to investigate yet.