diff --git a/README.md b/README.md index 38ec325..0534b38 100644 --- a/README.md +++ b/README.md @@ -292,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/flake.lock b/flake.lock index 823f0fb..9c5513e 100644 --- a/flake.lock +++ b/flake.lock @@ -1,153 +1,171 @@ { "nodes": { - "libcamera-apps-src": { - "flake": false, - "locked": { - "lastModified": 1713431793, - "narHash": "sha256-uoewZMGf3vsBoRDfRz8KBKl+J6st/J44SHvNRMBdaUI=", - "owner": "raspberrypi", - "repo": "libcamera-apps", - "rev": "414a7383464b98f21f5e5381a16cc73ae0350ba6", - "type": "github" - }, - "original": { - "owner": "raspberrypi", - "ref": "v1.4.4", - "repo": "libcamera-apps", - "type": "github" - } - }, "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", "repo": "libcamera", - "rev": "eb00c13d7c9f937732305d47af5b8ccf895e700f", + "rev": "6ddd79b5bdbedc1f61007aed35391f1559f9e29a", "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": 1718835956, + "narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9a9960b98418f8c385f52de3b09a63f9c561427a", + "rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309", "type": "github" }, "original": { "owner": "NixOS", + "ref": "nixos-24.05", "repo": "nixpkgs", - "rev": "9a9960b98418f8c385f52de3b09a63f9c561427a", "type": "github" } }, "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_10_0-rc5-src": "rpi-linux-6_10_0-rc5-src", + "rpi-linux-6_6_31-src": "rpi-linux-6_6_31-src", + "rpicam-apps-src": "rpicam-apps-src", "u-boot-src": "u-boot-src" } }, "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", + "ref": "bookworm", "repo": "bluez-firmware", - "rev": "d9d4741caba7314d6500f588b1eaa5ab387a4ff5", "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", + "ref": "bookworm", "repo": "firmware-nonfree", - "rev": "88aa085bfa1a4650e1ccd88896f8343c22a24055", "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" } }, - "rpi-linux-6_6-src": { + "rpi-linux-6_10_0-rc5-src": { + "flake": false, + "locked": { + "lastModified": 1719265450, + "narHash": "sha256-xd/Pz/uZFYW9hJIFKryWDE9Aks6f2EIvEDCmfk0C70c=", + "owner": "raspberrypi", + "repo": "linux", + "rev": "f61d3aca8045e70d64b55f7b98f083738f639ad2", + "type": "github" + }, + "original": { + "owner": "raspberrypi", + "ref": "rpi-6.10.y", + "repo": "linux", + "type": "github" + } + }, + "rpi-linux-6_6_31-src": { "flake": false, "locked": { - "lastModified": 1713516936, - "narHash": "sha256-mlsDuVczu0e57BlD/iq7IEEluOIgqbZ+W4Ju30E/zhw=", + "lastModified": 1716545726, + "narHash": "sha256-UWUTeCpEN7dlFSQjog6S3HyEWCCnaqiUqV5KxCjYink=", "owner": "raspberrypi", "repo": "linux", - "rev": "0c341f47adc3578cd5f817aa20ee2b7f9ae6b23e", + "rev": "c1432b4bae5b6582f4d32ba381459f33c34d1424", "type": "github" }, "original": { "owner": "raspberrypi", - "ref": "stable_20240423", + "ref": "stable_20240529", "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 35eb3a6..d127311 100644 --- a/flake.nix +++ b/flake.nix @@ -2,38 +2,42 @@ description = "raspberry-pi nixos configuration"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/9a9960b98418f8c385f52de3b09a63f9c561427a"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05"; u-boot-src = { 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_20240423"; + url = "github:raspberrypi/linux/stable_20240529"; + }; + rpi-linux-6_10_0-rc5-src = { + flake = false; + url = "github:raspberrypi/linux/rpi-6.10.y"; }; 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/bookworm"; }; rpi-bluez-firmware-src = { flake = false; - url = "github:RPi-Distro/bluez-firmware/d9d4741caba7314d6500f588b1eaa5ab387a4ff5"; + url = "github:RPi-Distro/bluez-firmware/bookworm"; }; - libcamera-apps-src = { + rpicam-apps-src = { flake = false; - url = "github:raspberrypi/libcamera-apps/v1.4.4"; + url = "github:raspberrypi/rpicam-apps/v1.5.0"; }; libcamera-src = { flake = false; - url = "github:raspberrypi/libcamera/eb00c13d7c9f937732305d47af5b8ccf895e700f"; # v0.2.0+rpt20240418 + url = "github:raspberrypi/libcamera/6ddd79b5bdbedc1f61007aed35391f1559f9e29a"; # v0.3.0+rpt20240617 }; libpisp-src = { flake = false; - url = "github:raspberrypi/libpisp/v1.0.5"; + url = "github:raspberrypi/libpisp/v1.0.6"; }; }; @@ -55,9 +59,9 @@ libcamera-overlay = self.overlays.libcamera; }; packages.aarch64-linux = { - linux = pinned.rpi-kernels.latest.kernel; - firmware = pinned.rpi-kernels.latest.firmware; - wireless-firmware = pinned.rpi-kernels.latest.wireless-firmware; + kernels = pinned.rpi-kernels; + 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 0d65aa5..c5cb91f 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_10_0-rc5-src , rpi-firmware-src , rpi-firmware-nonfree-src , rpi-bluez-firmware-src @@ -7,31 +8,95 @@ }: final: prev: let - # The version to stick at `pkgs.rpi-kernels.latest' - latest = "v6_6_28"; + versions = { + 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 = 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 = final.fetchpatch { + url = "https://github.com/peat-psuwit/rpi-linux/commit/23431052d2dce8084b72e399fce82b05d86b847f.patch"; + hash = "sha256-UDX/BJCJG0WVndP/6PbPK+AZsfU3vVxDCrpn1kb1kqE="; + }; + } + ]; + }; + 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" ]; # Helpers for building the `pkgs.rpi-kernels' map. - rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null }: + rpi-kernel = { version, board }: let - new-kernel = prev.linux_rpi4.override { - argsOverride = { - src = kernel; - inherit version; - modDirVersion = version; - } // (if builtins.isNull argsOverride then { } else argsOverride); - }; - new-fw = prev.raspberrypifw.overrideAttrs (oldfw: { src = fw; }); - new-wireless-fw = final.callPackage wireless-fw { }; - version-slug = builtins.replaceStrings [ "." ] [ "_" ] version; + kernel = builtins.getAttr version versions; + version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version; in { - "v${version-slug}" = { - kernel = new-kernel; - firmware = new-fw; - wireless-firmware = new-wireless-fw; - }; + "${version}"."${board}" = (final.buildLinux { + modDirVersion = version-slug; + version = version-slug; + pname = "linux-rpi"; + 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 + # 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; + 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) { }; + 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 @@ -40,7 +105,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" ]; @@ -61,46 +126,23 @@ in }; # default to latest firmware - raspberrypiWirelessFirmware = final.rpi-kernels.latest.wireless-firmware; - raspberrypifw = final.rpi-kernels.latest.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.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.v6_6_31.bcm2712' + rpi-kernels = rpi-kernels ( + final.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 4869ed0..ba887cf 100644 --- a/overlays/libcamera.nix +++ b/overlays/libcamera.nix @@ -1,17 +1,17 @@ -{ 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"; - version = "1.0.3"; + version = "1.0.6"; src = libpisp-src; nativeBuildInputs = with final; [ pkg-config meson ninja ]; buildInputs = with final; [ nlohmann_json boost ]; @@ -22,9 +22,29 @@ 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/overlays/libcamera-apps.nix b/overlays/rpicam-apps.nix similarity index 67% rename from overlays/libcamera-apps.nix rename to overlays/rpicam-apps.nix index df92f34..85529fb 100644 --- a/overlays/libcamera-apps.nix +++ b/overlays/rpicam-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/rpi/default.nix b/rpi/default.nix index 66ad9e4..df52430 100644 --- a/rpi/default.nix +++ b/rpi/default.nix @@ -3,12 +3,29 @@ let cfg = config.raspberry-pi-nix; + version = cfg.kernel-version; + board = cfg.board; + 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; + 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; @@ -96,8 +113,8 @@ 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" - KERNEL="${pkgs.rpi-kernels.latest.kernel}/Image" + 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" STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf) @@ -114,7 +131,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" } @@ -125,7 +142,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" } @@ -175,13 +192,13 @@ 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 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,10 +318,9 @@ 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; loader = { grub.enable = lib.mkDefault false; initScript.enable = !cfg.uboot.enable; diff --git a/sd-image/default.nix b/sd-image/default.nix index 52016a2..d1dc124 100644 --- a/sd-image/default.nix +++ b/sd-image/default.nix @@ -19,13 +19,17 @@ ${lib.strings.concatStringsSep " " config.boot.kernelParams} ''; }; + cfg = config.raspberry-pi-nix; + version = cfg.kernel-version; + board = cfg.board; + 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 "${pkgs.rpi-kernels.latest.kernel}/Image" firmware/kernel.img + cp "${kernel}/Image" firmware/kernel.img cp "${kernel-params}" firmware/cmdline.txt ''; in @@ -36,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