From 25b82e07556045b0b80a3d6cf2c8c408f6bf40f2 Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Wed, 18 Feb 2026 18:44:47 -0500 Subject: [PATCH 1/8] chore: format raspberry-pi/ with `nixfmt --strict` --- raspberry-pi/2/default.nix | 6 +----- raspberry-pi/3/default.nix | 12 ++---------- raspberry-pi/4/default.nix | 10 ++-------- raspberry-pi/4/leds.nix | 6 +++--- raspberry-pi/4/pkgs-overlays.nix | 4 +--- raspberry-pi/4/xhci.nix | 6 +----- raspberry-pi/5/default.nix | 7 ++----- 7 files changed, 12 insertions(+), 39 deletions(-) diff --git a/raspberry-pi/2/default.nix b/raspberry-pi/2/default.nix index c9178874..66f2bc62 100644 --- a/raspberry-pi/2/default.nix +++ b/raspberry-pi/2/default.nix @@ -4,11 +4,7 @@ boot = { consoleLogLevel = lib.mkDefault 7; kernelPackages = lib.mkDefault ( - pkgs.linuxPackagesFor ( - pkgs.callPackage ../common/kernel.nix { - rpiVersion = 2; - } - ) + pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 2; }) ); kernelParams = [ "dwc_otg.lpm_enable=0" diff --git a/raspberry-pi/3/default.nix b/raspberry-pi/3/default.nix index 6472c6b9..31146ac8 100644 --- a/raspberry-pi/3/default.nix +++ b/raspberry-pi/3/default.nix @@ -1,17 +1,9 @@ -{ - lib, - pkgs, - ... -}: +{ lib, pkgs, ... }: { boot = { kernelPackages = lib.mkDefault ( - pkgs.linuxPackagesFor ( - pkgs.callPackage ../common/kernel.nix { - rpiVersion = 3; - } - ) + pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 3; }) ); initrd.availableKernelModules = [ "usbhid" diff --git a/raspberry-pi/4/default.nix b/raspberry-pi/4/default.nix index 9efb4fcd..8bcd615b 100644 --- a/raspberry-pi/4/default.nix +++ b/raspberry-pi/4/default.nix @@ -29,11 +29,7 @@ boot = { kernelPackages = lib.mkDefault ( - pkgs.linuxPackagesFor ( - pkgs.callPackage ../common/kernel.nix { - rpiVersion = 4; - } - ) + pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 4; }) ); initrd.availableKernelModules = [ "usbhid" @@ -62,7 +58,5 @@ } ]; - hardware.firmware = [ - (pkgs.callPackage ../common/raspberry-pi-wireless-firmware.nix { }) - ]; + hardware.firmware = [ (pkgs.callPackage ../common/raspberry-pi-wireless-firmware.nix { }) ]; } diff --git a/raspberry-pi/4/leds.nix b/raspberry-pi/4/leds.nix index 3860fff5..27de0382 100644 --- a/raspberry-pi/4/leds.nix +++ b/raspberry-pi/4/leds.nix @@ -14,9 +14,9 @@ in { options.hardware = { raspberry-pi."4".leds = { - eth.disable = mkDisableOption ''ethernet LEDs.''; - act.disable = mkDisableOption ''activity LED.''; - pwr.disable = mkDisableOption ''power LED.''; + eth.disable = mkDisableOption "ethernet LEDs."; + act.disable = mkDisableOption "activity LED."; + pwr.disable = mkDisableOption "power LED."; }; }; diff --git a/raspberry-pi/4/pkgs-overlays.nix b/raspberry-pi/4/pkgs-overlays.nix index f36577a5..0588dc2d 100644 --- a/raspberry-pi/4/pkgs-overlays.nix +++ b/raspberry-pi/4/pkgs-overlays.nix @@ -19,7 +19,5 @@ in }; }; - config = lib.mkIf cfg.enable { - nixpkgs.overlays = [ dt_ao_overlay ]; - }; + config = lib.mkIf cfg.enable { nixpkgs.overlays = [ dt_ao_overlay ]; }; } diff --git a/raspberry-pi/4/xhci.nix b/raspberry-pi/4/xhci.nix index 56503df3..dd90cb00 100644 --- a/raspberry-pi/4/xhci.nix +++ b/raspberry-pi/4/xhci.nix @@ -1,8 +1,4 @@ -{ - config, - lib, - ... -}: +{ config, lib, ... }: let cfg = config.hardware.raspberry-pi."4".xhci; in diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index f8d82a9a..899f0d2b 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -4,14 +4,11 @@ config, ... }: + { boot = { kernelPackages = lib.mkDefault ( - pkgs.linuxPackagesFor ( - pkgs.callPackage ../common/kernel.nix { - rpiVersion = 5; - } - ) + pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 5; }) ); initrd.availableKernelModules = [ "nvme" From 114dfa19897cf6875785ba5623a1a74f222b9b62 Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Thu, 19 Feb 2026 07:52:49 -0500 Subject: [PATCH 2/8] raspberry-pi: add `usb-storage` to common modules Raspberry Pi 2 will now have it too. --- raspberry-pi/2/default.nix | 2 ++ raspberry-pi/3/default.nix | 5 +---- raspberry-pi/4/default.nix | 2 +- raspberry-pi/5/default.nix | 3 ++- raspberry-pi/common/default.nix | 1 + 5 files changed, 7 insertions(+), 6 deletions(-) create mode 100644 raspberry-pi/common/default.nix diff --git a/raspberry-pi/2/default.nix b/raspberry-pi/2/default.nix index 66f2bc62..c7287d59 100644 --- a/raspberry-pi/2/default.nix +++ b/raspberry-pi/2/default.nix @@ -1,6 +1,8 @@ { lib, pkgs, ... }: { + imports = [ ../common/default.nix ]; + boot = { consoleLogLevel = lib.mkDefault 7; kernelPackages = lib.mkDefault ( diff --git a/raspberry-pi/3/default.nix b/raspberry-pi/3/default.nix index 31146ac8..5911e3e0 100644 --- a/raspberry-pi/3/default.nix +++ b/raspberry-pi/3/default.nix @@ -5,10 +5,7 @@ kernelPackages = lib.mkDefault ( pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 3; }) ); - initrd.availableKernelModules = [ - "usbhid" - "usb-storage" - ]; + initrd.availableKernelModules = [ "usbhid" ]; }; # fix the following error : diff --git a/raspberry-pi/4/default.nix b/raspberry-pi/4/default.nix index 8bcd615b..0b010afa 100644 --- a/raspberry-pi/4/default.nix +++ b/raspberry-pi/4/default.nix @@ -7,6 +7,7 @@ { imports = [ + ../common/default.nix ./audio.nix ./backlight.nix ./bluetooth.nix @@ -33,7 +34,6 @@ ); initrd.availableKernelModules = [ "usbhid" - "usb-storage" "vc4" "pcie-brcmstb" # required for the pcie bus to work "reset-raspberrypi" # required for vl805 firmware to load diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index 899f0d2b..079285b0 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -6,6 +6,8 @@ }: { + imports = [ ../common/default.nix ]; + boot = { kernelPackages = lib.mkDefault ( pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 5; }) @@ -13,7 +15,6 @@ initrd.availableKernelModules = [ "nvme" "usbhid" - "usb-storage" ]; }; diff --git a/raspberry-pi/common/default.nix b/raspberry-pi/common/default.nix new file mode 100644 index 00000000..332884b4 --- /dev/null +++ b/raspberry-pi/common/default.nix @@ -0,0 +1 @@ +{ boot.initrd.availableKernelModules = [ "usb-storage" ]; } From 9ad075ca00d5b757448c4af61a338949dbb7842a Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Thu, 19 Feb 2026 07:55:18 -0500 Subject: [PATCH 3/8] raspberry-pi: add `usbhid` to common modules Raspberry Pi 2 will now have it too. --- raspberry-pi/3/default.nix | 1 - raspberry-pi/4/default.nix | 1 - raspberry-pi/5/default.nix | 5 +---- raspberry-pi/common/default.nix | 7 ++++++- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/raspberry-pi/3/default.nix b/raspberry-pi/3/default.nix index 5911e3e0..333f2d3f 100644 --- a/raspberry-pi/3/default.nix +++ b/raspberry-pi/3/default.nix @@ -5,7 +5,6 @@ kernelPackages = lib.mkDefault ( pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 3; }) ); - initrd.availableKernelModules = [ "usbhid" ]; }; # fix the following error : diff --git a/raspberry-pi/4/default.nix b/raspberry-pi/4/default.nix index 0b010afa..cf71bc73 100644 --- a/raspberry-pi/4/default.nix +++ b/raspberry-pi/4/default.nix @@ -33,7 +33,6 @@ pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 4; }) ); initrd.availableKernelModules = [ - "usbhid" "vc4" "pcie-brcmstb" # required for the pcie bus to work "reset-raspberrypi" # required for vl805 firmware to load diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index 079285b0..1b83252d 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -12,10 +12,7 @@ kernelPackages = lib.mkDefault ( pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 5; }) ); - initrd.availableKernelModules = [ - "nvme" - "usbhid" - ]; + initrd.availableKernelModules = [ "nvme" ]; }; # Needed for Xorg to start (https://github.com/raspberrypi-ui/gldriver-test/blob/master/usr/lib/systemd/scripts/rp1_test.sh) diff --git a/raspberry-pi/common/default.nix b/raspberry-pi/common/default.nix index 332884b4..8bfa0161 100644 --- a/raspberry-pi/common/default.nix +++ b/raspberry-pi/common/default.nix @@ -1 +1,6 @@ -{ boot.initrd.availableKernelModules = [ "usb-storage" ]; } +{ + boot.initrd.availableKernelModules = [ + "usb-storage" + "usbhid" + ]; +} From 076b2a51166d378e75528d955176fbd62f472d71 Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Thu, 19 Feb 2026 07:48:26 -0500 Subject: [PATCH 4/8] raspberry-pi: add `vc4` to common modules Raspberry Pi 2 and 3 will now have it too. --- raspberry-pi/4/default.nix | 1 - raspberry-pi/common/default.nix | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/raspberry-pi/4/default.nix b/raspberry-pi/4/default.nix index cf71bc73..41fcea85 100644 --- a/raspberry-pi/4/default.nix +++ b/raspberry-pi/4/default.nix @@ -33,7 +33,6 @@ pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 4; }) ); initrd.availableKernelModules = [ - "vc4" "pcie-brcmstb" # required for the pcie bus to work "reset-raspberrypi" # required for vl805 firmware to load ] diff --git a/raspberry-pi/common/default.nix b/raspberry-pi/common/default.nix index 8bfa0161..11f2cfc7 100644 --- a/raspberry-pi/common/default.nix +++ b/raspberry-pi/common/default.nix @@ -2,5 +2,6 @@ boot.initrd.availableKernelModules = [ "usb-storage" "usbhid" + "vc4" ]; } From d736553cca52feaf93efd7303b72dbf6eec70992 Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Wed, 18 Feb 2026 18:47:51 -0500 Subject: [PATCH 5/8] raspberry-pi/5: filter Device Tree blobs --- raspberry-pi/5/default.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index 1b83252d..99ab771e 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -15,6 +15,8 @@ initrd.availableKernelModules = [ "nvme" ]; }; + hardware.deviceTree.filter = lib.mkDefault "bcm2712*-rpi-*.dtb"; + # Needed for Xorg to start (https://github.com/raspberrypi-ui/gldriver-test/blob/master/usr/lib/systemd/scripts/rp1_test.sh) # This won't work for displays connected to the RP1 (DPI/composite/MIPI DSI), since I don't have one to test. services.xserver.extraConfig = '' From 722ef6b5be77ea84b1d320d5b759698be684213b Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Thu, 19 Feb 2026 08:00:16 -0500 Subject: [PATCH 6/8] raspberry-pi/5: add `pcie-brcmstb` module --- raspberry-pi/5/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index 99ab771e..bc2bc79d 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -12,7 +12,10 @@ kernelPackages = lib.mkDefault ( pkgs.linuxPackagesFor (pkgs.callPackage ../common/kernel.nix { rpiVersion = 5; }) ); - initrd.availableKernelModules = [ "nvme" ]; + initrd.availableKernelModules = [ + "nvme" + "pcie-brcmstb" + ]; }; hardware.deviceTree.filter = lib.mkDefault "bcm2712*-rpi-*.dtb"; From 011660e3f7480f3ea807bb0e53003e6961872d12 Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Thu, 19 Feb 2026 08:09:59 -0500 Subject: [PATCH 7/8] raspberry-pi/5: add modules for RP1 controller --- raspberry-pi/5/default.nix | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index bc2bc79d..d90c7886 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -5,6 +5,9 @@ ... }: +let + linuxVariant = config.boot.kernelPackages.kernel.pname; +in { imports = [ ../common/default.nix ]; @@ -15,7 +18,13 @@ initrd.availableKernelModules = [ "nvme" "pcie-brcmstb" - ]; + "clk-rp1" + ] + # CONFIG_MISC_RP1 is named CONFIG_MFD_RP1 in RPi's fork. + ++ lib.optional (linuxVariant == "linux") "rp1_pci" + ++ lib.optional (linuxVariant == "linux-rpi") "rp1" + # CONFIG_PINCTRL_RP1 is not a tristate in RPi's fork. + ++ lib.optional (linuxVariant == "linux") "pinctrl-rp1"; }; hardware.deviceTree.filter = lib.mkDefault "bcm2712*-rpi-*.dtb"; From 34360c4c63708a104ef6ab621dc1cae831e091a2 Mon Sep 17 00:00:00 2001 From: "Issam E. Maghni" Date: Thu, 19 Feb 2026 08:16:39 -0500 Subject: [PATCH 8/8] raspberry-pi/5: add `macb` module if netboot This module is required to have Ethernet in initial RAM disk. --- raspberry-pi/5/default.nix | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/raspberry-pi/5/default.nix b/raspberry-pi/5/default.nix index d90c7886..535588ee 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -24,7 +24,8 @@ in ++ lib.optional (linuxVariant == "linux") "rp1_pci" ++ lib.optional (linuxVariant == "linux-rpi") "rp1" # CONFIG_PINCTRL_RP1 is not a tristate in RPi's fork. - ++ lib.optional (linuxVariant == "linux") "pinctrl-rp1"; + ++ lib.optional (linuxVariant == "linux") "pinctrl-rp1" + ++ lib.optional config.boot.initrd.network.enable "macb"; }; hardware.deviceTree.filter = lib.mkDefault "bcm2712*-rpi-*.dtb";