NixOS on ARM/Raspberry Pi 4
The Raspberry Pi family of devices is a series of single-board computers made by the Raspberry Pi Foundation. They are all based on Broadcom System-on-a-chip (SOCs).
Raspberry Pi 4 Family | |
---|---|
(Image not available) | |
Manufacturer | Raspberry Pi Foundation |
Architecture | AArch64 |
Bootloader | Custom or U-Boot |
Boot order | Configurable; SD, USB, Netboot |
Maintainer | |
Raspberry Pi 4B | |
SoC | BCM2711 |
Status
The default Linux kernel in use, is the Raspberry Pi Foundation's fork. This will change for the mainline kernel once its support for the Raspberry Pi 4 Family is good enough to allow the user to boot, configure, and rebuild a system.
The Raspberry Pi 4 Family is only supported as AArch64. Use as armv7 is community supported.
Board-specific installation notes
First follow the generic installation steps to get the installer image and install using the installation and configuration steps.
Raspberry Pi 4B
Support for the Pi 4 in nixpkgs is still experimental. These configurations will boot (from this PR comment):
Until the generic image works, a temporary device-specific image is build on Hydra. Note that this image is not using u-boot, but rather the Raspberry Pi specific bootloader configuration.
The following configuration samples are built on the assumption that they are added to a configuration generated using nixos-generate-config
.
Without GPU
/etc/nixos/configuration.nix
{ pkgs, ... }:
{
networking.wireless.enable = false;
services.xserver = {
enable = true;
displayManager.slim.enable = true;
desktopManager.gnome3.enable = true;
videoDrivers = [ "fbdev" ];
};
}
With GPU
/etc/nixos/configuration.nix
{ pkgs, ... }:
{
networking.wireless.enable = false;
hardware.opengl = {
enable = true;
setLdLibraryPath = true;
package = pkgs.mesa_drivers;
};
hardware.deviceTree = {
base = pkgs.device-tree_rpi;
overlays = [ "${pkgs.device-tree_rpi.overlays}/vc4-fkms-v3d.dtbo" ];
};
services.xserver = {
enable = true;
displayManager.slim.enable = true;
desktopManager.gnome3.enable = true;
videoDrivers = [ "modesetting" ];
};
boot.loader.raspberryPi.firmwareConfig = ''
gpu_mem=192
'';
}
Tools
The raspberry tools are available in the raspberrypi-tools
package and include commands like vcgencmd
to measure temperature and CPU frequency.
Audio
In addition to the usual config, you will need to enable audio support explicitly in the firmwareConfig.
/etc/nixos/configuration.nix
sound.enable = true;
hardware.pulseaudio.enable = true;
boot.loader.raspberryPi.firmwareConfig = ''
dtparam=audio=on
'';
Troubleshooting
Power issues
The Raspberry Pi 4B is as power-hungry, if not more, as its predecessors. It is important to have a sufficient enough power supply or weirdness may happen. Weirdness may include:
- Lightning bolt on HDMI output "breaking" the display.
- Screen switching back to u-boot text
- Fixable temporarily when power is sufficient by switching VT (alt+F2 / alt+F1)
- Random hangs
Note that the Type-C USB receptacle for the Raspberry Pi 4B does not implement Power Delivery (USB PD). This means that it is limited to whatever the power supply will provide when not negotiating power, which is most likely 5V at some undetermined power level.