feat: bump all software & kernel, fix libcamera issues, load versions dynamically, 6.14 support

This commit is contained in:
adminy 2025-03-22 12:43:18 +00:00
parent 3e8100d5e9
commit c635f54fbd
7 changed files with 180 additions and 153 deletions

View file

@ -1,7 +1,8 @@
{ rpi-linux-stable-src
, rpi-linux-6_6_78-src
, rpi-linux-6_12_17-src
, rpi-firmware-src
{ lock
, rpi-linux-6_6_y-src
, rpi-linux-6_14_y-src
, rpi-firmware-6_6_y-src
, rpi-firmware-6_14_y-src
, rpi-firmware-nonfree-src
, rpi-bluez-firmware-src
, ...
@ -9,20 +10,15 @@
final: prev:
let
versions = {
v6_6_51.src = rpi-linux-stable-src;
v6_6_78.src = rpi-linux-6_6_78-src;
v6_12_17 = {
src = rpi-linux-6_12_17-src;
patches = [
{
name = "remove-readme-target.patch";
patch = final.fetchpatch {
url = "https://github.com/raspberrypi/linux/commit/3c0fd51d184f1748b83d28e1113265425c19bcb5.patch";
hash = "sha256-v7uZOmPCUp2i7NGVgjqnQYe6dEBD+aATuP/oRs9jfuk=";
};
}
];
v6_6_78 = {
src = rpi-linux-6_6_y-src;
firmware = rpi-firmware-6_6_y-src;
};
v6_14_0-rc7 = {
src = rpi-linux-6_14_y-src;
firmware = rpi-firmware-6_14_y-src;
};
};
boards = [ "bcm2711" "bcm2712" ];
@ -33,44 +29,48 @@ let
version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version;
in
{
"${version}"."${board}" = (final.buildLinux {
modDirVersion = version-slug;
version = version-slug;
pname = "linux-rpi";
src = kernel.src;
defconfig = "${board}_defconfig";
structuredExtraConfig = with final.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;
};
features.efiBootStub = false;
kernelPatches =
if kernel ? "patches" then kernel.patches else [ ];
ignoreConfigErrors = true;
}).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=""/'
'';
});
"${version}"."${board}" = {
kernel = (final.buildLinux {
modDirVersion = version-slug;
version = version-slug;
pname = "linux-rpi";
src = kernel.src;
defconfig = "${board}_defconfig";
structuredExtraConfig = with final.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;
HID_LENOVO = 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=""/'
'';
});
firmware = prev.raspberrypifw.overrideAttrs (oldfw: { src = kernel.firmware; });
};
};
rpi-kernels = builtins.foldl'
(b: a: final.lib.recursiveUpdate b (rpi-kernel a))
@ -108,13 +108,12 @@ in
}
)
{ };
raspberrypifw = prev.raspberrypifw.overrideAttrs (oldfw: { src = rpi-firmware-src; });
} // {
# rpi kernels and firmware are available at
# `pkgs.rpi-kernels.<VERSION>.<BOARD>'.
#
# For example: `pkgs.rpi-kernels.v6_6_78.bcm2712'
# Check all available versions/boards with: nix flake show
rpi-kernels = rpi-kernels (
final.lib.cartesianProduct
{ board = boards; version = (builtins.attrNames versions); }

View file

@ -1,6 +1,7 @@
{ rpicam-apps-src
, libcamera-src
, libpisp-src
, lock
, ...
}:
final: prev: {
@ -10,7 +11,7 @@ final: prev: {
libpisp = final.stdenv.mkDerivation {
name = "libpisp";
version = "1.0.7";
version = lock.nodes.libpisp-src.original.ref;
src = libpisp-src;
nativeBuildInputs = with final; [ pkg-config meson ninja ];
buildInputs = with final; [ nlohmann_json boost ];
@ -18,10 +19,15 @@ final: prev: {
# https://github.com/NixOS/nixpkgs/issues/86131
BOOST_INCLUDEDIR = "${prev.lib.getDev final.boost}/include";
BOOST_LIBRARYDIR = "${prev.lib.getLib final.boost}/lib";
# Copy image filters into lib
postInstall = ''
mkdir -p $out/lib/libpisp/backend
cp src/libpisp/backend/*.json $out/lib/libpisp/backend
'';
};
libcamera = prev.libcamera.overrideAttrs (old: {
version = "0.3.1";
version = lock.nodes.libcamera-src.original.ref;
src = libcamera-src;
buildInputs = old.buildInputs ++ (with final; [
libpisp
@ -50,8 +56,12 @@ final: prev: {
"-Dlc-compliance=disabled"
"-Dcam=disabled"
"-Dqcam=disabled"
"-Ddocumentation=enabled"
"-Ddocumentation=disabled"
"-Dpycamera=enabled"
];
# Issue introduced recently
# https://github.com/raspberrypi/libcamera/issues/226
CXXFLAGS = "-Wno-sign-compare -Wno-stringop-truncation";
});
}

View file

@ -6,7 +6,7 @@ stdenv.mkDerivation {
src = rpicam-apps-src;
nativeBuildInputs = with pkgs; [ meson pkg-config ];
nativeBuildInputs = with pkgs; [ meson pkg-config makeWrapper ];
buildInputs = with pkgs; [ libjpeg libtiff libcamera libepoxy boost libexif libpng ffmpeg libdrm ninja ];
mesonFlags = [
"-Denable_qt=disabled"
@ -21,6 +21,17 @@ stdenv.mkDerivation {
BOOST_INCLUDEDIR = "${lib.getDev pkgs.boost}/include";
BOOST_LIBRARYDIR = "${lib.getLib pkgs.boost}/lib";
postFixup = let
wrap = "wrapProgram $out/bin/rpicam";
ipa-var = "--set LIBCAMERA_IPA_PROXY_PATH ${pkgs.libcamera}/libexec/libcamera";
in ''
${wrap}-hello ${ipa-var}
${wrap}-raw ${ipa-var}
${wrap}-vid ${ipa-var}
${wrap}-jpeg ${ipa-var}
${wrap}-still ${ipa-var}
'';
meta = with lib; {
description = "Userland tools interfacing with Raspberry Pi cameras";
homepage = "https://github.com/raspberrypi/libcamera-apps";