From c2388c307b17de59ce3d57fe5feb052761905e88 Mon Sep 17 00:00:00 2001 From: adminy Date: Tue, 18 Jun 2024 23:58:46 +0100 Subject: [PATCH 01/18] chore: bump libs & fix libcamera, fix upstream nixpkgs --- flake.lock | 72 ++++++++--------- flake.nix | 21 ++--- overlays/default.nix | 93 ++++++++++++---------- overlays/libcamera-apps.nix | 24 +----- overlays/libcamera.nix | 27 ++++++- overlays/raspberrypi-wireless-firmware.nix | 4 +- rpi/default.nix | 24 ++++-- sd-image/default.nix | 4 +- 8 files changed, 149 insertions(+), 120 deletions(-) diff --git a/flake.lock b/flake.lock index 823f0fb..5d6ca0c 100644 --- a/flake.lock +++ b/flake.lock @@ -3,16 +3,16 @@ "libcamera-apps-src": { "flake": false, "locked": { - "lastModified": 1713431793, - "narHash": "sha256-uoewZMGf3vsBoRDfRz8KBKl+J6st/J44SHvNRMBdaUI=", + "lastModified": 1717081637, + "narHash": "sha256-s4zJh6r3VhiquO54KWZ78dVCH1BmlphY9zEB9BidNyo=", "owner": "raspberrypi", "repo": "libcamera-apps", - "rev": "414a7383464b98f21f5e5381a16cc73ae0350ba6", + "rev": "49344f2a8d1817558d4e6463032fcf11be618b38", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "v1.4.4", + "ref": "v1.5.0", "repo": "libcamera-apps", "type": "github" } @@ -20,50 +20,50 @@ "libcamera-src": { "flake": false, "locked": { - "lastModified": 1713446223, - "narHash": "sha256-p0/inkHPRUkxSIsTmj7VI7sIaX7OXdqjMGZ31W7cnt4=", + "lastModified": 1718617480, + "narHash": "sha256-qqEMJzMotybf1nJp1dsz3zc910Qj0TmqCm1CwuSb1VY=", "owner": "raspberrypi", "repo": "libcamera", - "rev": "eb00c13d7c9f937732305d47af5b8ccf895e700f", + "rev": "6ddd79b5bdbedc1f61007aed35391f1559f9e29a", "type": "github" }, "original": { "owner": "raspberrypi", + "ref": "v0.3.0+rpt20240617", "repo": "libcamera", - "rev": "eb00c13d7c9f937732305d47af5b8ccf895e700f", "type": "github" } }, "libpisp-src": { "flake": false, "locked": { - "lastModified": 1713362873, - "narHash": "sha256-CHd44CH5dBcZuK+5fZtONZ8HE/lwGKwK5U0BYUK8gG4=", + "lastModified": 1718613892, + "narHash": "sha256-V/d4RrXoq8HNc8r/Kr1gH3E7YTZzfIdgbaJtq/Xi7uQ=", "owner": "raspberrypi", "repo": "libpisp", - "rev": "999da5acb4f40cb8e93d22ec16e28edd55ec9414", + "rev": "b567f04556801ca350331ed21a1ae3eef4675c23", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "v1.0.5", + "ref": "v1.0.6", "repo": "libpisp", "type": "github" } }, "nixpkgs": { "locked": { - "lastModified": 1715218190, - "narHash": "sha256-R98WOBHkk8wIi103JUVQF3ei3oui4HvoZcz9tYOAwlk=", + "lastModified": 1718732645, + "narHash": "sha256-Zv8FapPPVVP5sqty4DWxSaL4p8sFuoAEglelBtSIhm0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9a9960b98418f8c385f52de3b09a63f9c561427a", + "rev": "9be7393d7204ba14ead6ec4f0381cc91bfb2aa24", "type": "github" }, "original": { "owner": "NixOS", "repo": "nixpkgs", - "rev": "9a9960b98418f8c385f52de3b09a63f9c561427a", + "rev": "9be7393d7204ba14ead6ec4f0381cc91bfb2aa24", "type": "github" } }, @@ -83,50 +83,50 @@ "rpi-bluez-firmware-src": { "flake": false, "locked": { - "lastModified": 1698157837, - "narHash": "sha256-CjbZ3t3TW/iJ3+t9QKEtM9NdQU7SwcUCDYuTmFEwvhU=", + "lastModified": 1708969706, + "narHash": "sha256-KakKnOBeWxh0exu44beZ7cbr5ni4RA9vkWYb9sGMb8Q=", "owner": "RPi-Distro", "repo": "bluez-firmware", - "rev": "d9d4741caba7314d6500f588b1eaa5ab387a4ff5", + "rev": "78d6a07730e2d20c035899521ab67726dc028e1c", "type": "github" }, "original": { "owner": "RPi-Distro", "repo": "bluez-firmware", - "rev": "d9d4741caba7314d6500f588b1eaa5ab387a4ff5", + "rev": "78d6a07730e2d20c035899521ab67726dc028e1c", "type": "github" } }, "rpi-firmware-nonfree-src": { "flake": false, "locked": { - "lastModified": 1700058854, - "narHash": "sha256-Yynww79LPPkau4YDSLI6IMOjH64nMpHUdGjnCfIR2+M=", + "lastModified": 1708967191, + "narHash": "sha256-BGq0+cr+xBRwQM/LqiQuRWuZpQsKM5jfcrNCqWMuVzM=", "owner": "RPi-Distro", "repo": "firmware-nonfree", - "rev": "88aa085bfa1a4650e1ccd88896f8343c22a24055", + "rev": "223ccf3a3ddb11b3ea829749fbbba4d65b380897", "type": "github" }, "original": { "owner": "RPi-Distro", "repo": "firmware-nonfree", - "rev": "88aa085bfa1a4650e1ccd88896f8343c22a24055", + "rev": "223ccf3a3ddb11b3ea829749fbbba4d65b380897", "type": "github" } }, "rpi-firmware-src": { "flake": false, "locked": { - "lastModified": 1713970515, - "narHash": "sha256-X5OinkLh/+mx34DM8mCk4tqOGuJdYxkvygv3gA77NJI=", + "lastModified": 1716978780, + "narHash": "sha256-KsCo7ZG6vKstxRyFljZtbQvnDSqiAPdUza32xTY/tlA=", "owner": "raspberrypi", "repo": "firmware", - "rev": "969420b4121b522ab33c5001074cc4c2547dafaf", + "rev": "3590de0c181d433af368a95f15bc480bdaff8b47", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "1.20240424", + "ref": "1.20240529", "repo": "firmware", "type": "github" } @@ -134,31 +134,31 @@ "rpi-linux-6_6-src": { "flake": false, "locked": { - "lastModified": 1713516936, - "narHash": "sha256-mlsDuVczu0e57BlD/iq7IEEluOIgqbZ+W4Ju30E/zhw=", + "lastModified": 1718722155, + "narHash": "sha256-WKlxHAAvDRN10M9pBmF3rNmXKd3uT2hv2/uxASa1LnQ=", "owner": "raspberrypi", "repo": "linux", - "rev": "0c341f47adc3578cd5f817aa20ee2b7f9ae6b23e", + "rev": "da87f91ad8450ccc5274cd7b6ba8d823b396c96f", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "stable_20240423", "repo": "linux", + "rev": "da87f91ad8450ccc5274cd7b6ba8d823b396c96f", "type": "github" } }, "u-boot-src": { "flake": false, "locked": { - "lastModified": 1712055538, - "narHash": "sha256-IlaDdjKq/Pq2orzcU959h93WXRZfvKBGDO/MFw9mZMg=", + "lastModified": 1717461299, + "narHash": "sha256-vcq+lR3Bw/Nreu8Muywvec4jUvZvodjk/E+8XkkKvZg=", "type": "tarball", - "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2" + "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2" }, "original": { "type": "tarball", - "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2" + "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2" } } }, diff --git a/flake.nix b/flake.nix index 35eb3a6..730f7a5 100644 --- a/flake.nix +++ b/flake.nix @@ -2,38 +2,38 @@ description = "raspberry-pi nixos configuration"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/9a9960b98418f8c385f52de3b09a63f9c561427a"; + nixpkgs.url = "github:NixOS/nixpkgs/9be7393d7204ba14ead6ec4f0381cc91bfb2aa24"; # 2024-06-18 u-boot-src = { flake = false; - url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2"; + url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2"; }; rpi-linux-6_6-src = { flake = false; - url = "github:raspberrypi/linux/stable_20240423"; + url = "github:raspberrypi/linux/da87f91ad8450ccc5274cd7b6ba8d823b396c96f"; # 2024-06-17 }; rpi-firmware-src = { flake = false; - url = "github:raspberrypi/firmware/1.20240424"; + url = "github:raspberrypi/firmware/1.20240529"; }; rpi-firmware-nonfree-src = { flake = false; - url = "github:RPi-Distro/firmware-nonfree/88aa085bfa1a4650e1ccd88896f8343c22a24055"; + url = "github:RPi-Distro/firmware-nonfree/223ccf3a3ddb11b3ea829749fbbba4d65b380897"; # 1:20230625-2+rpt2 }; rpi-bluez-firmware-src = { flake = false; - url = "github:RPi-Distro/bluez-firmware/d9d4741caba7314d6500f588b1eaa5ab387a4ff5"; + url = "github:RPi-Distro/bluez-firmware/78d6a07730e2d20c035899521ab67726dc028e1c"; # 1.2-9+rpt3 }; libcamera-apps-src = { flake = false; - url = "github:raspberrypi/libcamera-apps/v1.4.4"; + url = "github:raspberrypi/libcamera-apps/v1.5.0"; }; libcamera-src = { flake = false; - url = "github:raspberrypi/libcamera/eb00c13d7c9f937732305d47af5b8ccf895e700f"; # v0.2.0+rpt20240418 + url = "github:raspberrypi/libcamera/v0.3.0+rpt20240617"; }; libpisp-src = { flake = false; - url = "github:raspberrypi/libpisp/v1.0.5"; + url = "github:raspberrypi/libpisp/v1.0.6"; }; }; @@ -55,7 +55,8 @@ libcamera-overlay = self.overlays.libcamera; }; packages.aarch64-linux = { - linux = pinned.rpi-kernels.latest.kernel; + linux_2711 = pinned.rpi-kernels.latest_bcm2711.kernel; + linux_2712 = pinned.rpi-kernels.latest_bcm2712.kernel; firmware = pinned.rpi-kernels.latest.firmware; wireless-firmware = pinned.rpi-kernels.latest.wireless-firmware; uboot-rpi-arm64 = pinned.uboot-rpi-arm64; diff --git a/overlays/default.nix b/overlays/default.nix index 0d65aa5..dc71a19 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -7,17 +7,54 @@ }: final: prev: let - # The version to stick at `pkgs.rpi-kernels.latest' - latest = "v6_6_28"; + # The version to stick at `pkgs.rpi-kernels.latest_bcm271x' + latest = "v6_6_34"; + + kernel-config = board: { + inherit board; + version = builtins.replaceStrings ["v" "_"] ["" "."] latest; + kernel = rpi-linux-6_6-src; + fw = rpi-firmware-src; + wireless-fw = import ./raspberrypi-wireless-firmware.nix { + bluez-firmware = rpi-bluez-firmware-src; + firmware-nonfree = rpi-firmware-nonfree-src; + }; + argsOverride = { + structuredExtraConfig = with prev.lib.kernel; { + # The perl script to generate kernel options sets unspecified + # parameters to `m` if possible [1]. This results in the + # unspecified config option KUNIT [2] getting set to `m` which + # causes DRM_VC4_KUNIT_TEST [3] to get set to `y`. + # + # This vc4 unit test fails on boot due to a null pointer + # exception with the existing config. I'm not sure why, but in + # any case, the DRM_VC4_KUNIT_TEST config option itself states + # that it is only useful for kernel developers working on the + # vc4 driver. So, I feel no need to deviate from the standard + # rpi kernel and attempt to successfully enable this test and + # other unit tests because the nixos perl script has this + # sloppy "default to m" behavior. So, I set KUNIT to `n`. + # + # [1] https://github.com/NixOS/nixpkgs/blob/85bcb95aa83be667e562e781e9d186c57a07d757/pkgs/os-specific/linux/kernel/generate-config.pl#L1-L10 + # [2] https://github.com/raspberrypi/linux/blob/1.20230405/lib/kunit/Kconfig#L5-L14 + # [3] https://github.com/raspberrypi/linux/blob/bb63dc31e48948bc2649357758c7a152210109c4/drivers/gpu/drm/vc4/Kconfig#L38-L52 + KUNIT = no; + GPIO_PWM = no; + }; + }; + }; # Helpers for building the `pkgs.rpi-kernels' map. - rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null }: + rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null, board }: let new-kernel = prev.linux_rpi4.override { argsOverride = { src = kernel; inherit version; modDirVersion = version; + kernelPatches = []; + defconfig = "${board}_defconfig"; + postFixup = ""; } // (if builtins.isNull argsOverride then { } else argsOverride); }; new-fw = prev.raspberrypifw.overrideAttrs (oldfw: { src = fw; }); @@ -25,7 +62,7 @@ let version-slug = builtins.replaceStrings [ "." ] [ "_" ] version; in { - "v${version-slug}" = { + "latest_${board}" = { kernel = new-kernel; firmware = new-fw; wireless-firmware = new-wireless-fw; @@ -44,7 +81,7 @@ in defconfig = "rpi_arm64_defconfig"; extraMeta.platforms = [ "aarch64-linux" ]; filesToInstall = [ "u-boot.bin" ]; - version = "2024.04"; + version = "2024.07-rc4"; patches = [ ]; makeFlags = [ ]; src = u-boot-src; @@ -61,46 +98,16 @@ in }; # default to latest firmware - raspberrypiWirelessFirmware = final.rpi-kernels.latest.wireless-firmware; - raspberrypifw = final.rpi-kernels.latest.firmware; + raspberrypiWirelessFirmware = final.rpi-kernels.latest_bcm2712.wireless-firmware; + raspberrypifw = final.rpi-kernels.latest_bcm2712.firmware; } // { # rpi kernels and firmware are available at - # `pkgs.rpi-kernels..{kernel,firmware,wireless-firmware}'. + # `pkgs.rpi-kernels._.{kernel,firmware,wireless-firmware}'. # - # For example: `pkgs.rpi-kernels.v5_15_87.kernel' - rpi-kernels = rpi-kernels [{ - version = "6.6.28"; - kernel = rpi-linux-6_6-src; - fw = rpi-firmware-src; - wireless-fw = import ./raspberrypi-wireless-firmware.nix { - bluez-firmware = rpi-bluez-firmware-src; - firmware-nonfree = rpi-firmware-nonfree-src; - }; - argsOverride = { - structuredExtraConfig = with prev.lib.kernel; { - # The perl script to generate kernel options sets unspecified - # parameters to `m` if possible [1]. This results in the - # unspecified config option KUNIT [2] getting set to `m` which - # causes DRM_VC4_KUNIT_TEST [3] to get set to `y`. - # - # This vc4 unit test fails on boot due to a null pointer - # exception with the existing config. I'm not sure why, but in - # any case, the DRM_VC4_KUNIT_TEST config option itself states - # that it is only useful for kernel developers working on the - # vc4 driver. So, I feel no need to deviate from the standard - # rpi kernel and attempt to successfully enable this test and - # other unit tests because the nixos perl script has this - # sloppy "default to m" behavior. So, I set KUNIT to `n`. - # - # [1] https://github.com/NixOS/nixpkgs/blob/85bcb95aa83be667e562e781e9d186c57a07d757/pkgs/os-specific/linux/kernel/generate-config.pl#L1-L10 - # [2] https://github.com/raspberrypi/linux/blob/1.20230405/lib/kunit/Kconfig#L5-L14 - # [3] https://github.com/raspberrypi/linux/blob/bb63dc31e48948bc2649357758c7a152210109c4/drivers/gpu/drm/vc4/Kconfig#L38-L52 - KUNIT = no; - GPIO_PWM = no; - }; - }; - }] // { - latest = final.rpi-kernels."${latest}"; - }; + # For example: `pkgs.rpi-kernels.latest_bcm2712.kernel' + rpi-kernels = rpi-kernels [ + (kernel-config "bcm2711") + (kernel-config "bcm2712") + ]; } diff --git a/overlays/libcamera-apps.nix b/overlays/libcamera-apps.nix index df92f34..85529fb 100644 --- a/overlays/libcamera-apps.nix +++ b/overlays/libcamera-apps.nix @@ -1,28 +1,12 @@ -{ libcamera-apps-src -, lib -, stdenv -, fetchFromGitHub -, fetchpatch -, meson -, pkg-config -, libjpeg -, libtiff -, libpng -, libcamera -, libepoxy -, boost -, libexif -, ninja -}: - +{ libcamera-apps-src, lib, pkgs, stdenv }: stdenv.mkDerivation rec { pname = "libcamera-apps"; - version = "v1.4.1"; + version = "v1.5.0"; src = libcamera-apps-src; - nativeBuildInputs = [ meson pkg-config ]; - buildInputs = [ libjpeg libtiff libcamera libepoxy boost libexif libpng ninja ]; + nativeBuildInputs = with pkgs; [ meson pkg-config ]; + buildInputs = with pkgs; [ libjpeg libtiff libcamera libepoxy boost libexif libpng ninja ]; mesonFlags = [ "-Denable_qt=false" "-Denable_opencv=false" diff --git a/overlays/libcamera.nix b/overlays/libcamera.nix index 4869ed0..281979e 100644 --- a/overlays/libcamera.nix +++ b/overlays/libcamera.nix @@ -11,7 +11,7 @@ final: prev: libpisp = final.stdenv.mkDerivation { name = "libpisp"; - version = "1.0.3"; + version = "1.0.5"; src = libpisp-src; nativeBuildInputs = with final; [ pkg-config meson ninja ]; buildInputs = with final; [ nlohmann_json boost ]; @@ -22,9 +22,30 @@ final: prev: }; libcamera = prev.libcamera.overrideAttrs (old: { - version = "0.1.0"; + version = "0.2.0"; src = libcamera-src; - buildInputs = old.buildInputs ++ (with final; [ libpisp ]); + buildInputs = old.buildInputs ++ (with final; [ + libpisp openssl libtiff + (python3.withPackages (ps: with ps; [ + python3-gnutls pybind11 pyyaml ply + ])) + libglibutil gst_all_1.gst-plugins-base + + ]); patches = [ ]; + mesonFlags = [ + "--buildtype=release" + "-Dpipelines=rpi/vc4,rpi/pisp" + "-Dipas=rpi/vc4,rpi/pisp" + "-Dv4l2=true" + "-Dgstreamer=enabled" + "-Dtest=false" + "-Dlc-compliance=disabled" + "-Dcam=disabled" + "-Dqcam=disabled" + "-Ddocumentation=enabled" + "-Dpycamera=enabled" + ]; + }); } diff --git a/overlays/raspberrypi-wireless-firmware.nix b/overlays/raspberrypi-wireless-firmware.nix index 4e8217a..0e776ba 100644 --- a/overlays/raspberrypi-wireless-firmware.nix +++ b/overlays/raspberrypi-wireless-firmware.nix @@ -1,9 +1,9 @@ { bluez-firmware, firmware-nonfree }: -{ lib, stdenvNoCC, fetchFromGitHub }: +{ lib, stdenvNoCC }: stdenvNoCC.mkDerivation { pname = "raspberrypi-wireless-firmware"; - version = "2023-11-15"; + version = "2024-02-26"; srcs = [ ]; diff --git a/rpi/default.nix b/rpi/default.nix index 66ad9e4..4cd1900 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -3,12 +3,23 @@ let cfg = config.raspberry-pi-nix; + board = cfg.board; + kernel = pkgs.rpi-kernels."latest_${board}".kernel; in { imports = [ ../sd-image ./config.nix ./i2c.nix ]; options = with lib; { raspberry-pi-nix = { + board = mkOption { + default = "bcm2712"; + type = types.str; + description = '' + The kernel board version to build. + Examples at: https://github.com/NixOS/nixpkgs/blob/5c8e2fb3c690e8be1d92cda8d2bf0562cd67ce47/pkgs/os-specific/linux/kernel/linux-rpi.nix#L20-L25 + without the _defconfig part. + ''; + }; pin-inputs = { enable = mkOption { default = true; @@ -97,7 +108,7 @@ in TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays" TMPFILE="$TARGET_FIRMWARE_DIR/tmp" UBOOT="${pkgs.uboot_rpi_arm64}/u-boot.bin" - KERNEL="${pkgs.rpi-kernels.latest.kernel}/Image" + KERNEL="${kernel}/Image" SHOULD_UBOOT=${if cfg.uboot.enable then "1" else "0"} SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot" STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf) @@ -125,7 +136,7 @@ in cp "$KERNEL" "$TMPFILE" mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/kernel.img" echo "${ - builtins.toString pkgs.rpi-kernels.latest.kernel + builtins.toString kernel }" > "$STATE_DIRECTORY/kernel-version" rm "$STATE_DIRECTORY/kernel-migration-in-progress" } @@ -181,7 +192,7 @@ in fi if [[ "$SHOULD_UBOOT" -ne 1 ]] && [[ ! -f "$STATE_DIRECTORY/kernel-version" || $(< "$STATE_DIRECTORY/kernel-version") != ${ - builtins.toString pkgs.rpi-kernels.latest.kernel + builtins.toString kernel } ]]; then migrate_kernel fi @@ -301,9 +312,12 @@ in "reset-raspberrypi" # required for vl805 firmware to load ]; # This pin is not necessary, it would be fine to replace it with - # `pkgs.rpi-kernels.latest.kernel`. It is helpful to ensure + # `kernel`. It is helpful to ensure # cache hits for kernel builds though. - kernelPackages = pkgs.linuxPackagesFor pkgs.rpi-kernels.latest.kernel; + kernelPackages = pkgs.linuxPackagesFor (kernel.override { + # Some patches cannot be applied because they are already upstream. + ignoreConfigErrors = true; + }); loader = { grub.enable = lib.mkDefault false; diff --git a/sd-image/default.nix b/sd-image/default.nix index 52016a2..1dc4986 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -19,13 +19,15 @@ ${lib.strings.concatStringsSep " " config.boot.kernelParams} ''; }; + board = config.raspberry-pi-nix.board; + kernel = pkgs.rpi-kernels."latest_${board}".kernel; populate-kernel = if config.raspberry-pi-nix.uboot.enable then '' cp ${pkgs.uboot_rpi_arm64}/u-boot.bin firmware/u-boot-rpi-arm64.bin '' else '' - cp "${pkgs.rpi-kernels.latest.kernel}/Image" firmware/kernel.img + cp "${kernel}/Image" firmware/kernel.img cp "${kernel-params}" firmware/cmdline.txt ''; in From 5024cc20e2c2e4f66812841bdfb2f7ad4b8a310f Mon Sep 17 00:00:00 2001 From: adminy Date: Wed, 19 Jun 2024 00:32:04 +0100 Subject: [PATCH 02/18] add my kernel build cache url --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 38ec325..ed1ee21 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,10 @@ complete example. { description = "raspberry-pi-nix example"; nixConfig = { - extra-substituters = [ "https://raspberry-pi-nix.cachix.org" ]; + extra-substituters = [ "https://raspberry-pi-nix.cachix.org" https://adminy.cachix.org ]; extra-trusted-public-keys = [ "raspberry-pi-nix.cachix.org-1:WmV2rdSangxW0rZjY/tBvBDSaNFQ3DyEQsVw8EvHn9o=" + "adminy.cachix.org-1:xgrsLa9L9VCdTbY5dMDqtcl6qBFHA9U56SgEJosNbFc="" ]; }; inputs = { From 48bb6ed6fb3416e2683ee46a54abf1c78a8e51fc Mon Sep 17 00:00:00 2001 From: adminy Date: Wed, 19 Jun 2024 01:06:36 +0100 Subject: [PATCH 03/18] chore: remove unused --- overlays/default.nix | 1 - 1 file changed, 1 deletion(-) diff --git a/overlays/default.nix b/overlays/default.nix index dc71a19..d65548c 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -59,7 +59,6 @@ let }; new-fw = prev.raspberrypifw.overrideAttrs (oldfw: { src = fw; }); new-wireless-fw = final.callPackage wireless-fw { }; - version-slug = builtins.replaceStrings [ "." ] [ "_" ] version; in { "latest_${board}" = { From 4240bff28088c808bdf617e376bfef883b36730b Mon Sep 17 00:00:00 2001 From: adminy Date: Sat, 22 Jun 2024 16:32:44 +0100 Subject: [PATCH 04/18] chore: no double caching, compression now supported --- README.md | 5 +++-- overlays/default.nix | 5 ----- rpi/config.nix | 3 +-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ed1ee21..0534b38 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,9 @@ complete example. { description = "raspberry-pi-nix example"; nixConfig = { - extra-substituters = [ "https://raspberry-pi-nix.cachix.org" https://adminy.cachix.org ]; + extra-substituters = [ "https://raspberry-pi-nix.cachix.org" ]; extra-trusted-public-keys = [ "raspberry-pi-nix.cachix.org-1:WmV2rdSangxW0rZjY/tBvBDSaNFQ3DyEQsVw8EvHn9o=" - "adminy.cachix.org-1:xgrsLa9L9VCdTbY5dMDqtcl6qBFHA9U56SgEJosNbFc="" ]; }; inputs = { @@ -293,3 +292,5 @@ is kept up to date by the overlay applied by this package, so you don't need configure this. However, if you want to use different firmware you can override that package to do so. +## What's not working? +- [ ] Pi 5 u-boot devices other than sd-cards (i.e. usb, nvme). diff --git a/overlays/default.nix b/overlays/default.nix index d65548c..7eac593 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -70,11 +70,6 @@ let rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; in { - # disable firmware compression so that brcm firmware can be found at - # the path expected by raspberry pi firmware/device tree - compressFirmwareXz = x: x; - compressFirmwareZstd = x: x; - # provide generic rpi arm64 u-boot uboot_rpi_arm64 = prev.buildUBoot rec { defconfig = "rpi_arm64_defconfig"; diff --git a/rpi/config.nix b/rpi/config.nix index 125cb13..8a785f1 100644 --- a/rpi/config.nix +++ b/rpi/config.nix @@ -16,8 +16,7 @@ let (lib.filterAttrs (k: v: v.enable) x); render-dt-overlay = { overlay, args }: "dtoverlay=" + overlay + "\n" - + lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n" - + "dtoverlay="; + + lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n"; render-base-dt-params = params: lib.strings.concatMapStringsSep "\n" render-dt-param (render-dt-kvs params); From b9c9972ec614e67ce3d93890908e59254715053b Mon Sep 17 00:00:00 2001 From: adminy Date: Sat, 22 Jun 2024 23:49:48 +0100 Subject: [PATCH 05/18] chore: return to stable versions, undo compression, fix libcamera version --- flake.lock | 24 ++++++++++++------------ flake.nix | 10 +++++----- overlays/default.nix | 5 +++++ overlays/libcamera.nix | 2 +- 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/flake.lock b/flake.lock index 5d6ca0c..50e4485 100644 --- a/flake.lock +++ b/flake.lock @@ -6,14 +6,14 @@ "lastModified": 1717081637, "narHash": "sha256-s4zJh6r3VhiquO54KWZ78dVCH1BmlphY9zEB9BidNyo=", "owner": "raspberrypi", - "repo": "libcamera-apps", + "repo": "rpicam-apps", "rev": "49344f2a8d1817558d4e6463032fcf11be618b38", "type": "github" }, "original": { "owner": "raspberrypi", "ref": "v1.5.0", - "repo": "libcamera-apps", + "repo": "rpicam-apps", "type": "github" } }, @@ -53,17 +53,17 @@ }, "nixpkgs": { "locked": { - "lastModified": 1718732645, - "narHash": "sha256-Zv8FapPPVVP5sqty4DWxSaL4p8sFuoAEglelBtSIhm0=", + "lastModified": 1718835956, + "narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9be7393d7204ba14ead6ec4f0381cc91bfb2aa24", + "rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-24.05", "repo": "nixpkgs", - "rev": "9be7393d7204ba14ead6ec4f0381cc91bfb2aa24", "type": "github" } }, @@ -92,8 +92,8 @@ }, "original": { "owner": "RPi-Distro", + "ref": "bookworm", "repo": "bluez-firmware", - "rev": "78d6a07730e2d20c035899521ab67726dc028e1c", "type": "github" } }, @@ -109,8 +109,8 @@ }, "original": { "owner": "RPi-Distro", + "ref": "bookworm", "repo": "firmware-nonfree", - "rev": "223ccf3a3ddb11b3ea829749fbbba4d65b380897", "type": "github" } }, @@ -134,17 +134,17 @@ "rpi-linux-6_6-src": { "flake": false, "locked": { - "lastModified": 1718722155, - "narHash": "sha256-WKlxHAAvDRN10M9pBmF3rNmXKd3uT2hv2/uxASa1LnQ=", + "lastModified": 1716545726, + "narHash": "sha256-UWUTeCpEN7dlFSQjog6S3HyEWCCnaqiUqV5KxCjYink=", "owner": "raspberrypi", "repo": "linux", - "rev": "da87f91ad8450ccc5274cd7b6ba8d823b396c96f", + "rev": "c1432b4bae5b6582f4d32ba381459f33c34d1424", "type": "github" }, "original": { "owner": "raspberrypi", + "ref": "stable_20240529", "repo": "linux", - "rev": "da87f91ad8450ccc5274cd7b6ba8d823b396c96f", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 730f7a5..0d88847 100644 --- a/flake.nix +++ b/flake.nix @@ -2,14 +2,14 @@ description = "raspberry-pi nixos configuration"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/9be7393d7204ba14ead6ec4f0381cc91bfb2aa24"; # 2024-06-18 + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; u-boot-src = { flake = false; url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2"; }; rpi-linux-6_6-src = { flake = false; - url = "github:raspberrypi/linux/da87f91ad8450ccc5274cd7b6ba8d823b396c96f"; # 2024-06-17 + url = "github:raspberrypi/linux/stable_20240529"; }; rpi-firmware-src = { flake = false; @@ -17,15 +17,15 @@ }; rpi-firmware-nonfree-src = { flake = false; - url = "github:RPi-Distro/firmware-nonfree/223ccf3a3ddb11b3ea829749fbbba4d65b380897"; # 1:20230625-2+rpt2 + url = "github:RPi-Distro/firmware-nonfree/bookworm"; }; rpi-bluez-firmware-src = { flake = false; - url = "github:RPi-Distro/bluez-firmware/78d6a07730e2d20c035899521ab67726dc028e1c"; # 1.2-9+rpt3 + url = "github:RPi-Distro/bluez-firmware/bookworm"; }; libcamera-apps-src = { flake = false; - url = "github:raspberrypi/libcamera-apps/v1.5.0"; + url = "github:raspberrypi/rpicam-apps/v1.5.0"; }; libcamera-src = { flake = false; diff --git a/overlays/default.nix b/overlays/default.nix index 7eac593..d65548c 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -70,6 +70,11 @@ let rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; in { + # disable firmware compression so that brcm firmware can be found at + # the path expected by raspberry pi firmware/device tree + compressFirmwareXz = x: x; + compressFirmwareZstd = x: x; + # provide generic rpi arm64 u-boot uboot_rpi_arm64 = prev.buildUBoot rec { defconfig = "rpi_arm64_defconfig"; diff --git a/overlays/libcamera.nix b/overlays/libcamera.nix index 281979e..9758808 100644 --- a/overlays/libcamera.nix +++ b/overlays/libcamera.nix @@ -11,7 +11,7 @@ final: prev: libpisp = final.stdenv.mkDerivation { name = "libpisp"; - version = "1.0.5"; + version = "1.0.6"; src = libpisp-src; nativeBuildInputs = with final; [ pkg-config meson ninja ]; buildInputs = with final; [ nlohmann_json boost ]; From aa99f3a2ddc08a8c3c22f8a6ddcdd5ddd245a55e Mon Sep 17 00:00:00 2001 From: adminy Date: Sun, 23 Jun 2024 00:02:04 +0100 Subject: [PATCH 06/18] chore: downgrade u-boot to stable release --- flake.lock | 8 ++++---- flake.nix | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/flake.lock b/flake.lock index 50e4485..98fd4b3 100644 --- a/flake.lock +++ b/flake.lock @@ -151,14 +151,14 @@ "u-boot-src": { "flake": false, "locked": { - "lastModified": 1717461299, - "narHash": "sha256-vcq+lR3Bw/Nreu8Muywvec4jUvZvodjk/E+8XkkKvZg=", + "lastModified": 1712055538, + "narHash": "sha256-IlaDdjKq/Pq2orzcU959h93WXRZfvKBGDO/MFw9mZMg=", "type": "tarball", - "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2" + "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2" }, "original": { "type": "tarball", - "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2" + "url": "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2" } } }, diff --git a/flake.nix b/flake.nix index 0d88847..3a600c5 100644 --- a/flake.nix +++ b/flake.nix @@ -5,7 +5,7 @@ nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; u-boot-src = { flake = false; - url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.07-rc4.tar.bz2"; + url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2"; }; rpi-linux-6_6-src = { flake = false; From 57a532319e4198b858fce0f8a17b71012d143d85 Mon Sep 17 00:00:00 2001 From: adminy Date: Sun, 23 Jun 2024 02:00:09 +0100 Subject: [PATCH 07/18] chore: undo dtparams, improve kernel building code --- flake.nix | 8 +-- overlays/default.nix | 142 +++++++++++++++++++++++-------------------- rpi/config.nix | 3 +- rpi/default.nix | 10 ++- sd-image/default.nix | 3 +- 5 files changed, 93 insertions(+), 73 deletions(-) diff --git a/flake.nix b/flake.nix index 3a600c5..1000a07 100644 --- a/flake.nix +++ b/flake.nix @@ -55,10 +55,10 @@ libcamera-overlay = self.overlays.libcamera; }; packages.aarch64-linux = { - linux_2711 = pinned.rpi-kernels.latest_bcm2711.kernel; - linux_2712 = pinned.rpi-kernels.latest_bcm2712.kernel; - firmware = pinned.rpi-kernels.latest.firmware; - wireless-firmware = pinned.rpi-kernels.latest.wireless-firmware; + linux_2711 = pinned.rpi-kernels.v6_6_31.bcm2711; + linux_2712 = pinned.rpi-kernels.v6_6_31.bcm2712; + firmware = pinned.raspberrypifw; + wireless-firmware = pinned.raspberrypiWirelessFirmware; uboot-rpi-arm64 = pinned.uboot-rpi-arm64; }; }; diff --git a/overlays/default.nix b/overlays/default.nix index d65548c..ef0ceb5 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -7,66 +7,70 @@ }: final: prev: let - # The version to stick at `pkgs.rpi-kernels.latest_bcm271x' - latest = "v6_6_34"; - - kernel-config = board: { - inherit board; - version = builtins.replaceStrings ["v" "_"] ["" "."] latest; - kernel = rpi-linux-6_6-src; - fw = rpi-firmware-src; - wireless-fw = import ./raspberrypi-wireless-firmware.nix { - bluez-firmware = rpi-bluez-firmware-src; - firmware-nonfree = rpi-firmware-nonfree-src; - }; - argsOverride = { - structuredExtraConfig = with prev.lib.kernel; { - # The perl script to generate kernel options sets unspecified - # parameters to `m` if possible [1]. This results in the - # unspecified config option KUNIT [2] getting set to `m` which - # causes DRM_VC4_KUNIT_TEST [3] to get set to `y`. - # - # This vc4 unit test fails on boot due to a null pointer - # exception with the existing config. I'm not sure why, but in - # any case, the DRM_VC4_KUNIT_TEST config option itself states - # that it is only useful for kernel developers working on the - # vc4 driver. So, I feel no need to deviate from the standard - # rpi kernel and attempt to successfully enable this test and - # other unit tests because the nixos perl script has this - # sloppy "default to m" behavior. So, I set KUNIT to `n`. - # - # [1] https://github.com/NixOS/nixpkgs/blob/85bcb95aa83be667e562e781e9d186c57a07d757/pkgs/os-specific/linux/kernel/generate-config.pl#L1-L10 - # [2] https://github.com/raspberrypi/linux/blob/1.20230405/lib/kunit/Kconfig#L5-L14 - # [3] https://github.com/raspberrypi/linux/blob/bb63dc31e48948bc2649357758c7a152210109c4/drivers/gpu/drm/vc4/Kconfig#L38-L52 - KUNIT = no; - GPIO_PWM = no; - }; - }; + versions = { + v6_6_31 = rpi-linux-6_6-src; }; + boards = [ "bcmrpi" "bcm2709" "bcmrpi3" "bcm2711" "bcm2712" ]; # Helpers for building the `pkgs.rpi-kernels' map. - rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null, board }: - let - new-kernel = prev.linux_rpi4.override { - argsOverride = { - src = kernel; - inherit version; - modDirVersion = version; - kernelPatches = []; - defconfig = "${board}_defconfig"; - postFixup = ""; - } // (if builtins.isNull argsOverride then { } else argsOverride); - }; - new-fw = prev.raspberrypifw.overrideAttrs (oldfw: { src = fw; }); - new-wireless-fw = final.callPackage wireless-fw { }; - in - { - "latest_${board}" = { - kernel = new-kernel; - firmware = new-fw; - wireless-firmware = new-wireless-fw; - }; - }; + rpi-kernel = { version, board }: { + "${version}"."${board}" = prev.lib.overrideDerivation (prev.buildLinux { + modDirVersion = version; + inherit version; + pname = "linux-rpi"; + src = versions[version]; + defconfig = "${board}_defconfig"; + structuredExtraConfig = with lib.kernel; { + # Workaround https://github.com/raspberrypi/linux/issues/6198 + # Needed because NixOS 24.05+ sets DRM_SIMPLEDRM=y which pulls in + # DRM_KMS_HELPER=y. + BACKLIGHT_CLASS_DEVICE = yes; + # The perl script to generate kernel options sets unspecified + # parameters to `m` if possible [1]. This results in the + # unspecified config option KUNIT [2] getting set to `m` which + # causes DRM_VC4_KUNIT_TEST [3] to get set to `y`. + # + # This vc4 unit test fails on boot due to a null pointer + # exception with the existing config. I'm not sure why, but in + # any case, the DRM_VC4_KUNIT_TEST config option itself states + # that it is only useful for kernel developers working on the + # vc4 driver. So, I feel no need to deviate from the standard + # rpi kernel and attempt to successfully enable this test and + # other unit tests because the nixos perl script has this + # sloppy "default to m" behavior. So, I set KUNIT to `n`. + # + # [1] https://github.com/NixOS/nixpkgs/blob/85bcb95aa83be667e562e781e9d186c57a07d757/pkgs/os-specific/linux/kernel/generate-config.pl#L1-L10 + # [2] https://github.com/raspberrypi/linux/blob/1.20230405/lib/kunit/Kconfig#L5-L14 + # [3] https://github.com/raspberrypi/linux/blob/bb63dc31e48948bc2649357758c7a152210109c4/drivers/gpu/drm/vc4/Kconfig#L38-L52 + KUNIT = no; + }; + features.efiBootStub = false; + 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=""/' + ''; + postFixup = ""; + kernelPatches = [ + # Fix compilation errors due to incomplete patch backport. + # https://github.com/raspberrypi/linux/pull/6223 + { + name = "gpio-pwm_-_pwm_apply_might_sleep.patch"; + patch = fetchpatch { + url = "https://github.com/peat-psuwit/rpi-linux/commit/879f34b88c60dd59765caa30576cb5bfb8e73c56.patch"; + hash = "sha256-HlOkM9EFmlzOebCGoj7lNV5hc0wMjhaBFFZvaRCI0lI="; + }; + } + { + name = "ir-rx51_-_pwm_apply_might_sleep.patch"; + patch = fetchpatch { + url = "https://github.com/peat-psuwit/rpi-linux/commit/23431052d2dce8084b72e399fce82b05d86b847f.patch"; + hash = "sha256-UDX/BJCJG0WVndP/6PbPK+AZsfU3vVxDCrpn1kb1kqE="; + }; + } + ]; + }); + }; rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; in { @@ -80,7 +84,7 @@ in defconfig = "rpi_arm64_defconfig"; extraMeta.platforms = [ "aarch64-linux" ]; filesToInstall = [ "u-boot.bin" ]; - version = "2024.07-rc4"; + version = "2024.04"; patches = [ ]; makeFlags = [ ]; src = u-boot-src; @@ -97,16 +101,22 @@ in }; # default to latest firmware - raspberrypiWirelessFirmware = final.rpi-kernels.latest_bcm2712.wireless-firmware; - raspberrypifw = final.rpi-kernels.latest_bcm2712.firmware; + raspberrypiWirelessFirmware = final.callPackage ( + import ./raspberrypi-wireless-firmware.nix { + bluez-firmware = rpi-bluez-firmware-src; + firmware-nonfree = rpi-firmware-nonfree-src; + } + ) { }; + raspberrypifw = prev.raspberrypifw.overrideAttrs (oldfw: { src = rpi-firmware-src; }); } // { # rpi kernels and firmware are available at - # `pkgs.rpi-kernels._.{kernel,firmware,wireless-firmware}'. + # `pkgs.rpi-kernels..'. # - # For example: `pkgs.rpi-kernels.latest_bcm2712.kernel' - rpi-kernels = rpi-kernels [ - (kernel-config "bcm2711") - (kernel-config "bcm2712") - ]; + # For example: `pkgs.rpi-kernels.v6_6_31.bcm2712' + rpi-kernels = rpi-kernels ( + prev.lib.lists.crossLists + (board: version: { inherit board version; }) + [boards (builtins.attrNames versions)] + ); } diff --git a/rpi/config.nix b/rpi/config.nix index 8a785f1..125cb13 100644 --- a/rpi/config.nix +++ b/rpi/config.nix @@ -16,7 +16,8 @@ let (lib.filterAttrs (k: v: v.enable) x); render-dt-overlay = { overlay, args }: "dtoverlay=" + overlay + "\n" - + lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n"; + + lib.strings.concatMapStringsSep "\n" render-dt-param args + "\n" + + "dtoverlay="; render-base-dt-params = params: lib.strings.concatMapStringsSep "\n" render-dt-param (render-dt-kvs params); diff --git a/rpi/default.nix b/rpi/default.nix index 4cd1900..ed81385 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -4,13 +4,21 @@ let cfg = config.raspberry-pi-nix; board = cfg.board; - kernel = pkgs.rpi-kernels."latest_${board}".kernel; + version = cfg.kernel_version; + kernel = pkgs.rpi-kernels."${version}"."${board}"; in { imports = [ ../sd-image ./config.nix ./i2c.nix ]; options = with lib; { raspberry-pi-nix = { + kernel_version = mkOption { + default = "v6_6_31"; + type = types.str; + description = '' + Kernel version to build. + ''; + }; board = mkOption { default = "bcm2712"; type = types.str; diff --git a/sd-image/default.nix b/sd-image/default.nix index 1dc4986..b24c4e8 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -20,7 +20,8 @@ ''; }; board = config.raspberry-pi-nix.board; - kernel = pkgs.rpi-kernels."latest_${board}".kernel; + version = config.raspberry-pi-nix.kernel_version; + kernel = pkgs.rpi-kernels."${version}"."${board}"; populate-kernel = if config.raspberry-pi-nix.uboot.enable then '' From b027897628cc5dc69ad3e323d953dc5e7072f360 Mon Sep 17 00:00:00 2001 From: adminy Date: Sun, 23 Jun 2024 16:43:11 +0100 Subject: [PATCH 08/18] fix: fix targets for flake, add kernel 6.6.34 --- flake.lock | 58 +++++++++++------ flake.nix | 13 ++-- overlays/default.nix | 65 ++++++++++--------- overlays/libcamera.nix | 7 +- .../{libcamera-apps.nix => rpicam-apps.nix} | 0 rpi/default.nix | 10 +-- sd-image/default.nix | 11 ++-- 7 files changed, 97 insertions(+), 67 deletions(-) rename overlays/{libcamera-apps.nix => rpicam-apps.nix} (100%) diff --git a/flake.lock b/flake.lock index 98fd4b3..e2453ac 100644 --- a/flake.lock +++ b/flake.lock @@ -1,22 +1,5 @@ { "nodes": { - "libcamera-apps-src": { - "flake": false, - "locked": { - "lastModified": 1717081637, - "narHash": "sha256-s4zJh6r3VhiquO54KWZ78dVCH1BmlphY9zEB9BidNyo=", - "owner": "raspberrypi", - "repo": "rpicam-apps", - "rev": "49344f2a8d1817558d4e6463032fcf11be618b38", - "type": "github" - }, - "original": { - "owner": "raspberrypi", - "ref": "v1.5.0", - "repo": "rpicam-apps", - "type": "github" - } - }, "libcamera-src": { "flake": false, "locked": { @@ -69,14 +52,15 @@ }, "root": { "inputs": { - "libcamera-apps-src": "libcamera-apps-src", "libcamera-src": "libcamera-src", "libpisp-src": "libpisp-src", "nixpkgs": "nixpkgs", "rpi-bluez-firmware-src": "rpi-bluez-firmware-src", "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", "rpi-firmware-src": "rpi-firmware-src", - "rpi-linux-6_6-src": "rpi-linux-6_6-src", + "rpi-linux-6_6_31-src": "rpi-linux-6_6_31-src", + "rpi-linux-6_6_34-src": "rpi-linux-6_6_34-src", + "rpicam-apps-src": "rpicam-apps-src", "u-boot-src": "u-boot-src" } }, @@ -131,7 +115,7 @@ "type": "github" } }, - "rpi-linux-6_6-src": { + "rpi-linux-6_6_31-src": { "flake": false, "locked": { "lastModified": 1716545726, @@ -148,6 +132,40 @@ "type": "github" } }, + "rpi-linux-6_6_34-src": { + "flake": false, + "locked": { + "lastModified": 1718967581, + "narHash": "sha256-RMKvgdhHQQPSmGjAOpYYB7YpClPVks6f6Dw381qDYHY=", + "owner": "raspberrypi", + "repo": "linux", + "rev": "7af85d54e39733bb9a236b95ea5ed1ab8277d560", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "ref": "rpi-6.6.y", + "repo": "linux", + "type": "github" + } + }, + "rpicam-apps-src": { + "flake": false, + "locked": { + "lastModified": 1717081637, + "narHash": "sha256-s4zJh6r3VhiquO54KWZ78dVCH1BmlphY9zEB9BidNyo=", + "owner": "raspberrypi", + "repo": "rpicam-apps", + "rev": "49344f2a8d1817558d4e6463032fcf11be618b38", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "ref": "v1.5.0", + "repo": "rpicam-apps", + "type": "github" + } + }, "u-boot-src": { "flake": false, "locked": { diff --git a/flake.nix b/flake.nix index 1000a07..34a9bfd 100644 --- a/flake.nix +++ b/flake.nix @@ -7,10 +7,14 @@ flake = false; url = "https://ftp.denx.de/pub/u-boot/u-boot-2024.04.tar.bz2"; }; - rpi-linux-6_6-src = { + rpi-linux-6_6_31-src = { flake = false; url = "github:raspberrypi/linux/stable_20240529"; }; + rpi-linux-6_6_34-src = { + flake = false; + url = "github:raspberrypi/linux/rpi-6.6.y"; + }; rpi-firmware-src = { flake = false; url = "github:raspberrypi/firmware/1.20240529"; @@ -23,7 +27,7 @@ flake = false; url = "github:RPi-Distro/bluez-firmware/bookworm"; }; - libcamera-apps-src = { + rpicam-apps-src = { flake = false; url = "github:raspberrypi/rpicam-apps/v1.5.0"; }; @@ -55,8 +59,9 @@ libcamera-overlay = self.overlays.libcamera; }; packages.aarch64-linux = { - linux_2711 = pinned.rpi-kernels.v6_6_31.bcm2711; - linux_2712 = pinned.rpi-kernels.v6_6_31.bcm2712; + kernels = pinned.rpi-kernels; + # linux_2711 = pinned.rpi-kernels.v6_6_31.bcm2711; + # linux_2712 = pinned.rpi-kernels.v6_6_31.bcm2712; firmware = pinned.raspberrypifw; wireless-firmware = pinned.raspberrypiWirelessFirmware; uboot-rpi-arm64 = pinned.uboot-rpi-arm64; diff --git a/overlays/default.nix b/overlays/default.nix index ef0ceb5..01be479 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,5 +1,6 @@ { u-boot-src -, rpi-linux-6_6-src +, rpi-linux-6_6_31-src +, rpi-linux-6_6_34-src , rpi-firmware-src , rpi-firmware-nonfree-src , rpi-bluez-firmware-src @@ -8,19 +9,43 @@ final: prev: let versions = { - v6_6_31 = rpi-linux-6_6-src; + v6_6_31 = { + src = rpi-linux-6_6_31-src; + patches = [ + # Fix compilation errors due to incomplete patch backport. + # https://github.com/raspberrypi/linux/pull/6223 + { + name = "gpio-pwm_-_pwm_apply_might_sleep.patch"; + patch = prev.fetchpatch { + url = "https://github.com/peat-psuwit/rpi-linux/commit/879f34b88c60dd59765caa30576cb5bfb8e73c56.patch"; + hash = "sha256-HlOkM9EFmlzOebCGoj7lNV5hc0wMjhaBFFZvaRCI0lI="; + }; + } + { + name = "ir-rx51_-_pwm_apply_might_sleep.patch"; + patch = prev.fetchpatch { + url = "https://github.com/peat-psuwit/rpi-linux/commit/23431052d2dce8084b72e399fce82b05d86b847f.patch"; + hash = "sha256-UDX/BJCJG0WVndP/6PbPK+AZsfU3vVxDCrpn1kb1kqE="; + }; + } + ]; + }; + v6_6_34.src = rpi-linux-6_6_34-src; }; boards = [ "bcmrpi" "bcm2709" "bcmrpi3" "bcm2711" "bcm2712" ]; # Helpers for building the `pkgs.rpi-kernels' map. - rpi-kernel = { version, board }: { + rpi-kernel = { version, board }: let + kernel = versions[version]; + version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version; + in { "${version}"."${board}" = prev.lib.overrideDerivation (prev.buildLinux { - modDirVersion = version; - inherit version; + modDirVersion = version-slug; + version = version-slug; pname = "linux-rpi"; - src = versions[version]; + src = kernel.src; defconfig = "${board}_defconfig"; - structuredExtraConfig = with lib.kernel; { + structuredExtraConfig = with prev.lib.kernel; { # Workaround https://github.com/raspberrypi/linux/issues/6198 # Needed because NixOS 24.05+ sets DRM_SIMPLEDRM=y which pulls in # DRM_KMS_HELPER=y. @@ -51,24 +76,7 @@ let sed -i $buildRoot/include/config/auto.conf -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/' ''; postFixup = ""; - kernelPatches = [ - # Fix compilation errors due to incomplete patch backport. - # https://github.com/raspberrypi/linux/pull/6223 - { - name = "gpio-pwm_-_pwm_apply_might_sleep.patch"; - patch = fetchpatch { - url = "https://github.com/peat-psuwit/rpi-linux/commit/879f34b88c60dd59765caa30576cb5bfb8e73c56.patch"; - hash = "sha256-HlOkM9EFmlzOebCGoj7lNV5hc0wMjhaBFFZvaRCI0lI="; - }; - } - { - name = "ir-rx51_-_pwm_apply_might_sleep.patch"; - patch = fetchpatch { - url = "https://github.com/peat-psuwit/rpi-linux/commit/23431052d2dce8084b72e399fce82b05d86b847f.patch"; - hash = "sha256-UDX/BJCJG0WVndP/6PbPK+AZsfU3vVxDCrpn1kb1kqE="; - }; - } - ]; + kernelPatches = if kernel.patches != null then kernel.patches else []; }); }; rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; @@ -80,7 +88,7 @@ in compressFirmwareZstd = x: x; # provide generic rpi arm64 u-boot - uboot_rpi_arm64 = prev.buildUBoot rec { + uboot-rpi-arm64 = prev.buildUBoot rec { defconfig = "rpi_arm64_defconfig"; extraMeta.platforms = [ "aarch64-linux" ]; filesToInstall = [ "u-boot.bin" ]; @@ -115,8 +123,7 @@ in # # For example: `pkgs.rpi-kernels.v6_6_31.bcm2712' rpi-kernels = rpi-kernels ( - prev.lib.lists.crossLists - (board: version: { inherit board version; }) - [boards (builtins.attrNames versions)] + prev.lib.cartesianProductOfSets # this gets renamed yet again to cartesianProduct in April 19 2024 + { board = boards; version = (builtins.attrNames versions); } ); } diff --git a/overlays/libcamera.nix b/overlays/libcamera.nix index 9758808..ba887cf 100644 --- a/overlays/libcamera.nix +++ b/overlays/libcamera.nix @@ -1,13 +1,13 @@ -{ libcamera-apps-src +{ rpicam-apps-src , libcamera-src , libpisp-src , ... }: final: prev: { - # A recent known working version of libcamera-apps + # A recent known working version of rpicam-apps libcamera-apps = - final.callPackage ./libcamera-apps.nix { inherit libcamera-apps-src; }; + final.callPackage ./rpicam-apps.nix { inherit rpicam-apps-src; }; libpisp = final.stdenv.mkDerivation { name = "libpisp"; @@ -46,6 +46,5 @@ final: prev: "-Ddocumentation=enabled" "-Dpycamera=enabled" ]; - }); } diff --git a/overlays/libcamera-apps.nix b/overlays/rpicam-apps.nix similarity index 100% rename from overlays/libcamera-apps.nix rename to overlays/rpicam-apps.nix diff --git a/rpi/default.nix b/rpi/default.nix index ed81385..1dcf2eb 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -4,7 +4,7 @@ let cfg = config.raspberry-pi-nix; board = cfg.board; - version = cfg.kernel_version; + version = cfg.kernel-version; kernel = pkgs.rpi-kernels."${version}"."${board}"; in { @@ -12,7 +12,7 @@ in options = with lib; { raspberry-pi-nix = { - kernel_version = mkOption { + kernel-version = mkOption { default = "v6_6_31"; type = types.str; description = '' @@ -115,7 +115,7 @@ in TARGET_FIRMWARE_DIR="${firmware-path}" TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays" TMPFILE="$TARGET_FIRMWARE_DIR/tmp" - UBOOT="${pkgs.uboot_rpi_arm64}/u-boot.bin" + UBOOT="${pkgs.uboot-rpi-arm64}/u-boot.bin" KERNEL="${kernel}/Image" SHOULD_UBOOT=${if cfg.uboot.enable then "1" else "0"} SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot" @@ -133,7 +133,7 @@ in cp "$UBOOT" "$TMPFILE" mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/u-boot-rpi-arm64.bin" echo "${ - builtins.toString pkgs.uboot_rpi_arm64 + builtins.toString pkgs.uboot-rpi-arm64 }" > "$STATE_DIRECTORY/uboot-version" rm "$STATE_DIRECTORY/uboot-migration-in-progress" } @@ -194,7 +194,7 @@ in } if [[ "$SHOULD_UBOOT" -eq 1 ]] && [[ -f "$STATE_DIRECTORY/uboot-migration-in-progress" || ! -f "$STATE_DIRECTORY/uboot-version" || $(< "$STATE_DIRECTORY/uboot-version") != ${ - builtins.toString pkgs.uboot_rpi_arm64 + builtins.toString pkgs.uboot-rpi-arm64 } ]]; then migrate_uboot fi diff --git a/sd-image/default.nix b/sd-image/default.nix index b24c4e8..98aa3e1 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -19,13 +19,14 @@ ${lib.strings.concatStringsSep " " config.boot.kernelParams} ''; }; - board = config.raspberry-pi-nix.board; - version = config.raspberry-pi-nix.kernel_version; + cfg = config.raspberry-pi-nix; + board = cfg.board; + version = cfg.kernel-version; kernel = pkgs.rpi-kernels."${version}"."${board}"; populate-kernel = - if config.raspberry-pi-nix.uboot.enable + if cfg.uboot.enable then '' - cp ${pkgs.uboot_rpi_arm64}/u-boot.bin firmware/u-boot-rpi-arm64.bin + cp ${pkgs.uboot-rpi-arm64}/u-boot.bin firmware/u-boot-rpi-arm64.bin '' else '' cp "${kernel}/Image" firmware/kernel.img @@ -39,7 +40,7 @@ cp ${config.hardware.raspberry-pi.config-output} firmware/config.txt ''; populateRootCommands = - if config.raspberry-pi-nix.uboot.enable + if cfg.uboot.enable then '' mkdir -p ./files/boot ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot From 9113306d60bda3b0d6c0223773bb19857da42661 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:11:22 -0400 Subject: [PATCH 09/18] run nixpkgs-fmt --- overlays/default.nix | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/overlays/default.nix b/overlays/default.nix index 01be479..4611cf2 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -35,11 +35,13 @@ let boards = [ "bcmrpi" "bcm2709" "bcmrpi3" "bcm2711" "bcm2712" ]; # Helpers for building the `pkgs.rpi-kernels' map. - rpi-kernel = { version, board }: let - kernel = versions[version]; - version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version; - in { - "${version}"."${board}" = prev.lib.overrideDerivation (prev.buildLinux { + rpi-kernel = { version, board }: + let + kernel = versions [ version ]; + version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version; + in + { + "${version}"."${board}" = prev.lib.overrideDerivation (prev.buildLinux { modDirVersion = version-slug; version = version-slug; pname = "linux-rpi"; @@ -76,9 +78,9 @@ let sed -i $buildRoot/include/config/auto.conf -e 's/^CONFIG_LOCALVERSION=.*/CONFIG_LOCALVERSION=""/' ''; postFixup = ""; - kernelPatches = if kernel.patches != null then kernel.patches else []; - }); - }; + kernelPatches = if kernel.patches != null then kernel.patches else [ ]; + }); + }; rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; in { @@ -109,12 +111,14 @@ in }; # default to latest firmware - raspberrypiWirelessFirmware = final.callPackage ( - import ./raspberrypi-wireless-firmware.nix { - bluez-firmware = rpi-bluez-firmware-src; - firmware-nonfree = rpi-firmware-nonfree-src; - } - ) { }; + raspberrypiWirelessFirmware = final.callPackage + ( + import ./raspberrypi-wireless-firmware.nix { + bluez-firmware = rpi-bluez-firmware-src; + firmware-nonfree = rpi-firmware-nonfree-src; + } + ) + { }; raspberrypifw = prev.raspberrypifw.overrideAttrs (oldfw: { src = rpi-firmware-src; }); } // { From 50e36bf86a956e2016f38283b6ee04812fbf175f Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:13:52 -0400 Subject: [PATCH 10/18] fix version lookup --- overlays/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/overlays/default.nix b/overlays/default.nix index 4611cf2..d8f328f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -37,7 +37,7 @@ let # Helpers for building the `pkgs.rpi-kernels' map. rpi-kernel = { version, board }: let - kernel = versions [ version ]; + kernel = builtins.getAttr version versions; version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version; in { From f0c963957bdc931ac35943d1fa31c99b6db35521 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:18:51 -0400 Subject: [PATCH 11/18] remove overrideDerivation It wasn't fully applied and it isn't necessary for these overrides anyway --- overlays/default.nix | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/overlays/default.nix b/overlays/default.nix index d8f328f..5f5850f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -41,13 +41,13 @@ let version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version; in { - "${version}"."${board}" = prev.lib.overrideDerivation (prev.buildLinux { + "${version}"."${board}" = (final.buildLinux { modDirVersion = version-slug; version = version-slug; pname = "linux-rpi"; src = kernel.src; defconfig = "${board}_defconfig"; - structuredExtraConfig = with prev.lib.kernel; { + structuredExtraConfig = with final.lib.kernel; { # Workaround https://github.com/raspberrypi/linux/issues/6198 # Needed because NixOS 24.05+ sets DRM_SIMPLEDRM=y which pulls in # DRM_KMS_HELPER=y. @@ -72,14 +72,16 @@ let KUNIT = no; }; features.efiBootStub = false; - 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=""/' - ''; - postFixup = ""; - kernelPatches = if kernel.patches != null then kernel.patches else [ ]; - }); + kernelPatches = + if kernel ? "patches" then kernel.patches else [ ]; + }).overrideAttrs + (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=""/' + ''; + }); }; rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; in From 7f3a320cc09443d4166347cb03e23d8d7f7b0e43 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:20:26 -0400 Subject: [PATCH 12/18] fix clobbering of all but one board per version --- overlays/default.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/overlays/default.nix b/overlays/default.nix index 5f5850f..72f2437 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -83,7 +83,9 @@ let ''; }); }; - rpi-kernels = builtins.foldl' (b: a: b // rpi-kernel a) { }; + rpi-kernels = builtins.foldl' + (b: a: final.lib.recursiveUpdate b (rpi-kernel a)) + { }; in { # disable firmware compression so that brcm firmware can be found at From 4f517c83bfccdfc9a8930fda8c022012766324d9 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:21:22 -0400 Subject: [PATCH 13/18] use final when appropriate --- overlays/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/overlays/default.nix b/overlays/default.nix index 72f2437..4b7a5f5 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -16,14 +16,14 @@ let # https://github.com/raspberrypi/linux/pull/6223 { name = "gpio-pwm_-_pwm_apply_might_sleep.patch"; - patch = prev.fetchpatch { + patch = final.fetchpatch { url = "https://github.com/peat-psuwit/rpi-linux/commit/879f34b88c60dd59765caa30576cb5bfb8e73c56.patch"; hash = "sha256-HlOkM9EFmlzOebCGoj7lNV5hc0wMjhaBFFZvaRCI0lI="; }; } { name = "ir-rx51_-_pwm_apply_might_sleep.patch"; - patch = prev.fetchpatch { + patch = final.fetchpatch { url = "https://github.com/peat-psuwit/rpi-linux/commit/23431052d2dce8084b72e399fce82b05d86b847f.patch"; hash = "sha256-UDX/BJCJG0WVndP/6PbPK+AZsfU3vVxDCrpn1kb1kqE="; }; @@ -94,7 +94,7 @@ in compressFirmwareZstd = x: x; # provide generic rpi arm64 u-boot - uboot-rpi-arm64 = prev.buildUBoot rec { + uboot-rpi-arm64 = final.buildUBoot rec { defconfig = "rpi_arm64_defconfig"; extraMeta.platforms = [ "aarch64-linux" ]; filesToInstall = [ "u-boot.bin" ]; @@ -131,7 +131,7 @@ in # # For example: `pkgs.rpi-kernels.v6_6_31.bcm2712' rpi-kernels = rpi-kernels ( - prev.lib.cartesianProductOfSets # this gets renamed yet again to cartesianProduct in April 19 2024 + final.lib.cartesianProductOfSets # this gets renamed yet again to cartesianProduct in April 19 2024 { board = boards; version = (builtins.attrNames versions); } ); } From 16d872085fe10077bd6665e2652582f013107e65 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:24:34 -0400 Subject: [PATCH 14/18] Avoid tags with `+` in them due to parsing bug https://github.com/NixOS/nix/issues/6688 --- flake.lock | 2 +- flake.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/flake.lock b/flake.lock index e2453ac..99b2d11 100644 --- a/flake.lock +++ b/flake.lock @@ -12,8 +12,8 @@ }, "original": { "owner": "raspberrypi", - "ref": "v0.3.0+rpt20240617", "repo": "libcamera", + "rev": "6ddd79b5bdbedc1f61007aed35391f1559f9e29a", "type": "github" } }, diff --git a/flake.nix b/flake.nix index 34a9bfd..b218e6c 100644 --- a/flake.nix +++ b/flake.nix @@ -33,7 +33,7 @@ }; libcamera-src = { flake = false; - url = "github:raspberrypi/libcamera/v0.3.0+rpt20240617"; + url = "github:raspberrypi/libcamera/6ddd79b5bdbedc1f61007aed35391f1559f9e29a"; # v0.3.0+rpt20240617 }; libpisp-src = { flake = false; From 40011886152e5299a098f04bf80d2ee64df74370 Mon Sep 17 00:00:00 2001 From: Travis Staton Date: Mon, 24 Jun 2024 09:26:37 -0400 Subject: [PATCH 15/18] remove package comment --- flake.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/flake.nix b/flake.nix index b218e6c..7289281 100644 --- a/flake.nix +++ b/flake.nix @@ -60,8 +60,6 @@ }; packages.aarch64-linux = { kernels = pinned.rpi-kernels; - # linux_2711 = pinned.rpi-kernels.v6_6_31.bcm2711; - # linux_2712 = pinned.rpi-kernels.v6_6_31.bcm2712; firmware = pinned.raspberrypifw; wireless-firmware = pinned.raspberrypiWirelessFirmware; uboot-rpi-arm64 = pinned.uboot-rpi-arm64; From caed11b1f6273ddd10460a033cfaf5230d843cdd Mon Sep 17 00:00:00 2001 From: adminy Date: Tue, 25 Jun 2024 00:12:11 +0100 Subject: [PATCH 16/18] chore: remove error silencing --- rpi/default.nix | 12 +++--------- sd-image/default.nix | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/rpi/default.nix b/rpi/default.nix index 1dcf2eb..df52430 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -3,8 +3,8 @@ let cfg = config.raspberry-pi-nix; - board = cfg.board; version = cfg.kernel-version; + board = cfg.board; kernel = pkgs.rpi-kernels."${version}"."${board}"; in { @@ -15,9 +15,7 @@ in kernel-version = mkOption { default = "v6_6_31"; type = types.str; - description = '' - Kernel version to build. - ''; + description = "Kernel version to build."; }; board = mkOption { default = "bcm2712"; @@ -322,11 +320,7 @@ in # This pin is not necessary, it would be fine to replace it with # `kernel`. It is helpful to ensure # cache hits for kernel builds though. - kernelPackages = pkgs.linuxPackagesFor (kernel.override { - # Some patches cannot be applied because they are already upstream. - ignoreConfigErrors = true; - }); - + kernelPackages = pkgs.linuxPackagesFor kernel; loader = { grub.enable = lib.mkDefault false; initScript.enable = !cfg.uboot.enable; diff --git a/sd-image/default.nix b/sd-image/default.nix index 98aa3e1..d1dc124 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -20,8 +20,8 @@ ''; }; cfg = config.raspberry-pi-nix; - board = cfg.board; version = cfg.kernel-version; + board = cfg.board; kernel = pkgs.rpi-kernels."${version}"."${board}"; populate-kernel = if cfg.uboot.enable From 196c7f8e4b2dce3510abdb10296ea8f6032e73bc Mon Sep 17 00:00:00 2001 From: adminy Date: Fri, 28 Jun 2024 07:53:31 +0100 Subject: [PATCH 17/18] chore: build latest kernel --- flake.lock | 22 +++++++++++----------- flake.nix | 4 ++-- overlays/default.nix | 19 +++++++++++++------ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index 99b2d11..9c5513e 100644 --- a/flake.lock +++ b/flake.lock @@ -58,8 +58,8 @@ "rpi-bluez-firmware-src": "rpi-bluez-firmware-src", "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", "rpi-firmware-src": "rpi-firmware-src", + "rpi-linux-6_10_0-rc5-src": "rpi-linux-6_10_0-rc5-src", "rpi-linux-6_6_31-src": "rpi-linux-6_6_31-src", - "rpi-linux-6_6_34-src": "rpi-linux-6_6_34-src", "rpicam-apps-src": "rpicam-apps-src", "u-boot-src": "u-boot-src" } @@ -115,36 +115,36 @@ "type": "github" } }, - "rpi-linux-6_6_31-src": { + "rpi-linux-6_10_0-rc5-src": { "flake": false, "locked": { - "lastModified": 1716545726, - "narHash": "sha256-UWUTeCpEN7dlFSQjog6S3HyEWCCnaqiUqV5KxCjYink=", + "lastModified": 1719265450, + "narHash": "sha256-xd/Pz/uZFYW9hJIFKryWDE9Aks6f2EIvEDCmfk0C70c=", "owner": "raspberrypi", "repo": "linux", - "rev": "c1432b4bae5b6582f4d32ba381459f33c34d1424", + "rev": "f61d3aca8045e70d64b55f7b98f083738f639ad2", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "stable_20240529", + "ref": "rpi-6.10.y", "repo": "linux", "type": "github" } }, - "rpi-linux-6_6_34-src": { + "rpi-linux-6_6_31-src": { "flake": false, "locked": { - "lastModified": 1718967581, - "narHash": "sha256-RMKvgdhHQQPSmGjAOpYYB7YpClPVks6f6Dw381qDYHY=", + "lastModified": 1716545726, + "narHash": "sha256-UWUTeCpEN7dlFSQjog6S3HyEWCCnaqiUqV5KxCjYink=", "owner": "raspberrypi", "repo": "linux", - "rev": "7af85d54e39733bb9a236b95ea5ed1ab8277d560", + "rev": "c1432b4bae5b6582f4d32ba381459f33c34d1424", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "rpi-6.6.y", + "ref": "stable_20240529", "repo": "linux", "type": "github" } diff --git a/flake.nix b/flake.nix index 7289281..d127311 100644 --- a/flake.nix +++ b/flake.nix @@ -11,9 +11,9 @@ flake = false; url = "github:raspberrypi/linux/stable_20240529"; }; - rpi-linux-6_6_34-src = { + rpi-linux-6_10_0-rc5-src = { flake = false; - url = "github:raspberrypi/linux/rpi-6.6.y"; + url = "github:raspberrypi/linux/rpi-6.10.y"; }; rpi-firmware-src = { flake = false; diff --git a/overlays/default.nix b/overlays/default.nix index 4b7a5f5..058ef30 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -1,6 +1,6 @@ { u-boot-src , rpi-linux-6_6_31-src -, rpi-linux-6_6_34-src +, rpi-linux-6_10_0-rc5-src , rpi-firmware-src , rpi-firmware-nonfree-src , rpi-bluez-firmware-src @@ -30,7 +30,18 @@ let } ]; }; - v6_6_34.src = rpi-linux-6_6_34-src; + v6_10_0-rc5 = { + src = rpi-linux-6_10_0-rc5-src; + patches = [ + { + name = "remove-readme-target.patch"; + patch = final.fetchpatch { + url = "https://github.com/raspberrypi/linux/commit/3c0fd51d184f1748b83d28e1113265425c19bcb5.patch"; + hash = "sha256-v7uZOmPCUp2i7NGVgjqnQYe6dEBD+aATuP/oRs9jfuk="; + }; + } + ]; + }; }; boards = [ "bcmrpi" "bcm2709" "bcmrpi3" "bcm2711" "bcm2712" ]; @@ -48,10 +59,6 @@ let src = kernel.src; defconfig = "${board}_defconfig"; structuredExtraConfig = with final.lib.kernel; { - # Workaround https://github.com/raspberrypi/linux/issues/6198 - # Needed because NixOS 24.05+ sets DRM_SIMPLEDRM=y which pulls in - # DRM_KMS_HELPER=y. - BACKLIGHT_CLASS_DEVICE = yes; # The perl script to generate kernel options sets unspecified # parameters to `m` if possible [1]. This results in the # unspecified config option KUNIT [2] getting set to `m` which From 25b88136ac3a0cc15e29275db556ebed565686cb Mon Sep 17 00:00:00 2001 From: adminy Date: Fri, 28 Jun 2024 09:37:03 +0100 Subject: [PATCH 18/18] chore: undo backlight --- overlays/default.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/overlays/default.nix b/overlays/default.nix index 058ef30..c5cb91f 100644 --- a/overlays/default.nix +++ b/overlays/default.nix @@ -59,6 +59,10 @@ let src = kernel.src; defconfig = "${board}_defconfig"; structuredExtraConfig = with final.lib.kernel; { + # Workaround https://github.com/raspberrypi/linux/issues/6198 + # Needed because NixOS 24.05+ sets DRM_SIMPLEDRM=y which pulls in + # DRM_KMS_HELPER=y. + BACKLIGHT_CLASS_DEVICE = yes; # The perl script to generate kernel options sets unspecified # parameters to `m` if possible [1]. This results in the # unspecified config option KUNIT [2] getting set to `m` which