diff --git a/raspberry-pi/2/default.nix b/raspberry-pi/2/default.nix index c9178874..c7287d59 100644 --- a/raspberry-pi/2/default.nix +++ b/raspberry-pi/2/default.nix @@ -1,14 +1,12 @@ { lib, pkgs, ... }: { + imports = [ ../common/default.nix ]; + 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..333f2d3f 100644 --- a/raspberry-pi/3/default.nix +++ b/raspberry-pi/3/default.nix @@ -1,22 +1,10 @@ -{ - 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" - "usb-storage" - ]; }; # fix the following error : diff --git a/raspberry-pi/4/default.nix b/raspberry-pi/4/default.nix index 9efb4fcd..41fcea85 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 @@ -29,16 +30,9 @@ 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" - "usb-storage" - "vc4" "pcie-brcmstb" # required for the pcie bus to work "reset-raspberrypi" # required for vl805 firmware to load ] @@ -62,7 +56,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..535588ee 100644 --- a/raspberry-pi/5/default.nix +++ b/raspberry-pi/5/default.nix @@ -4,22 +4,32 @@ config, ... }: + +let + linuxVariant = config.boot.kernelPackages.kernel.pname; +in { + imports = [ ../common/default.nix ]; + 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" - "usbhid" - "usb-storage" - ]; + "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" + ++ lib.optional config.boot.initrd.network.enable "macb"; }; + 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 = '' diff --git a/raspberry-pi/common/default.nix b/raspberry-pi/common/default.nix new file mode 100644 index 00000000..11f2cfc7 --- /dev/null +++ b/raspberry-pi/common/default.nix @@ -0,0 +1,7 @@ +{ + boot.initrd.availableKernelModules = [ + "usb-storage" + "usbhid" + "vc4" + ]; +}