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