Merge pull request #23 from adminy/upgrade-with-fixes

chore: bump libs & fix libcamera, fix upstream nixpkgs
This commit is contained in:
Travis Staton 2024-07-08 17:09:00 -04:00 committed by GitHub
commit c92bd86e0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 251 additions and 161 deletions

View file

@ -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 don't need configure this. However, if you want to use different
firmware you can override that package to do so. 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).

114
flake.lock generated
View file

@ -1,153 +1,171 @@
{ {
"nodes": { "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": { "libcamera-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1713446223, "lastModified": 1718617480,
"narHash": "sha256-p0/inkHPRUkxSIsTmj7VI7sIaX7OXdqjMGZ31W7cnt4=", "narHash": "sha256-qqEMJzMotybf1nJp1dsz3zc910Qj0TmqCm1CwuSb1VY=",
"owner": "raspberrypi", "owner": "raspberrypi",
"repo": "libcamera", "repo": "libcamera",
"rev": "eb00c13d7c9f937732305d47af5b8ccf895e700f", "rev": "6ddd79b5bdbedc1f61007aed35391f1559f9e29a",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "raspberrypi", "owner": "raspberrypi",
"repo": "libcamera", "repo": "libcamera",
"rev": "eb00c13d7c9f937732305d47af5b8ccf895e700f", "rev": "6ddd79b5bdbedc1f61007aed35391f1559f9e29a",
"type": "github" "type": "github"
} }
}, },
"libpisp-src": { "libpisp-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1713362873, "lastModified": 1718613892,
"narHash": "sha256-CHd44CH5dBcZuK+5fZtONZ8HE/lwGKwK5U0BYUK8gG4=", "narHash": "sha256-V/d4RrXoq8HNc8r/Kr1gH3E7YTZzfIdgbaJtq/Xi7uQ=",
"owner": "raspberrypi", "owner": "raspberrypi",
"repo": "libpisp", "repo": "libpisp",
"rev": "999da5acb4f40cb8e93d22ec16e28edd55ec9414", "rev": "b567f04556801ca350331ed21a1ae3eef4675c23",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "raspberrypi", "owner": "raspberrypi",
"ref": "v1.0.5", "ref": "v1.0.6",
"repo": "libpisp", "repo": "libpisp",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1715218190, "lastModified": 1718835956,
"narHash": "sha256-R98WOBHkk8wIi103JUVQF3ei3oui4HvoZcz9tYOAwlk=", "narHash": "sha256-wM9v2yIxClRYsGHut5vHICZTK7xdrUGfrLkXvSuv6s4=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9a9960b98418f8c385f52de3b09a63f9c561427a", "rev": "dd457de7e08c6d06789b1f5b88fc9327f4d96309",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "NixOS", "owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "9a9960b98418f8c385f52de3b09a63f9c561427a",
"type": "github" "type": "github"
} }
}, },
"root": { "root": {
"inputs": { "inputs": {
"libcamera-apps-src": "libcamera-apps-src",
"libcamera-src": "libcamera-src", "libcamera-src": "libcamera-src",
"libpisp-src": "libpisp-src", "libpisp-src": "libpisp-src",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"rpi-bluez-firmware-src": "rpi-bluez-firmware-src", "rpi-bluez-firmware-src": "rpi-bluez-firmware-src",
"rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src", "rpi-firmware-nonfree-src": "rpi-firmware-nonfree-src",
"rpi-firmware-src": "rpi-firmware-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" "u-boot-src": "u-boot-src"
} }
}, },
"rpi-bluez-firmware-src": { "rpi-bluez-firmware-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1698157837, "lastModified": 1708969706,
"narHash": "sha256-CjbZ3t3TW/iJ3+t9QKEtM9NdQU7SwcUCDYuTmFEwvhU=", "narHash": "sha256-KakKnOBeWxh0exu44beZ7cbr5ni4RA9vkWYb9sGMb8Q=",
"owner": "RPi-Distro", "owner": "RPi-Distro",
"repo": "bluez-firmware", "repo": "bluez-firmware",
"rev": "d9d4741caba7314d6500f588b1eaa5ab387a4ff5", "rev": "78d6a07730e2d20c035899521ab67726dc028e1c",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "RPi-Distro", "owner": "RPi-Distro",
"ref": "bookworm",
"repo": "bluez-firmware", "repo": "bluez-firmware",
"rev": "d9d4741caba7314d6500f588b1eaa5ab387a4ff5",
"type": "github" "type": "github"
} }
}, },
"rpi-firmware-nonfree-src": { "rpi-firmware-nonfree-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1700058854, "lastModified": 1708967191,
"narHash": "sha256-Yynww79LPPkau4YDSLI6IMOjH64nMpHUdGjnCfIR2+M=", "narHash": "sha256-BGq0+cr+xBRwQM/LqiQuRWuZpQsKM5jfcrNCqWMuVzM=",
"owner": "RPi-Distro", "owner": "RPi-Distro",
"repo": "firmware-nonfree", "repo": "firmware-nonfree",
"rev": "88aa085bfa1a4650e1ccd88896f8343c22a24055", "rev": "223ccf3a3ddb11b3ea829749fbbba4d65b380897",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "RPi-Distro", "owner": "RPi-Distro",
"ref": "bookworm",
"repo": "firmware-nonfree", "repo": "firmware-nonfree",
"rev": "88aa085bfa1a4650e1ccd88896f8343c22a24055",
"type": "github" "type": "github"
} }
}, },
"rpi-firmware-src": { "rpi-firmware-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1713970515, "lastModified": 1716978780,
"narHash": "sha256-X5OinkLh/+mx34DM8mCk4tqOGuJdYxkvygv3gA77NJI=", "narHash": "sha256-KsCo7ZG6vKstxRyFljZtbQvnDSqiAPdUza32xTY/tlA=",
"owner": "raspberrypi", "owner": "raspberrypi",
"repo": "firmware", "repo": "firmware",
"rev": "969420b4121b522ab33c5001074cc4c2547dafaf", "rev": "3590de0c181d433af368a95f15bc480bdaff8b47",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "raspberrypi", "owner": "raspberrypi",
"ref": "1.20240424", "ref": "1.20240529",
"repo": "firmware", "repo": "firmware",
"type": "github" "type": "github"
} }
}, },
"rpi-linux-6_6-src": { "rpi-linux-6_10_0-rc5-src": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1713516936, "lastModified": 1719265450,
"narHash": "sha256-mlsDuVczu0e57BlD/iq7IEEluOIgqbZ+W4Ju30E/zhw=", "narHash": "sha256-xd/Pz/uZFYW9hJIFKryWDE9Aks6f2EIvEDCmfk0C70c=",
"owner": "raspberrypi", "owner": "raspberrypi",
"repo": "linux", "repo": "linux",
"rev": "0c341f47adc3578cd5f817aa20ee2b7f9ae6b23e", "rev": "f61d3aca8045e70d64b55f7b98f083738f639ad2",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "raspberrypi", "owner": "raspberrypi",
"ref": "stable_20240423", "ref": "rpi-6.10.y",
"repo": "linux", "repo": "linux",
"type": "github" "type": "github"
} }
}, },
"rpi-linux-6_6_31-src": {
"flake": false,
"locked": {
"lastModified": 1716545726,
"narHash": "sha256-UWUTeCpEN7dlFSQjog6S3HyEWCCnaqiUqV5KxCjYink=",
"owner": "raspberrypi",
"repo": "linux",
"rev": "c1432b4bae5b6582f4d32ba381459f33c34d1424",
"type": "github"
},
"original": {
"owner": "raspberrypi",
"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": { "u-boot-src": {
"flake": false, "flake": false,
"locked": { "locked": {

View file

@ -2,38 +2,42 @@
description = "raspberry-pi nixos configuration"; description = "raspberry-pi nixos configuration";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/9a9960b98418f8c385f52de3b09a63f9c561427a"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
u-boot-src = { u-boot-src = {
flake = false; 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.04.tar.bz2";
}; };
rpi-linux-6_6-src = { rpi-linux-6_6_31-src = {
flake = false; 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 = { rpi-firmware-src = {
flake = false; flake = false;
url = "github:raspberrypi/firmware/1.20240424"; url = "github:raspberrypi/firmware/1.20240529";
}; };
rpi-firmware-nonfree-src = { rpi-firmware-nonfree-src = {
flake = false; flake = false;
url = "github:RPi-Distro/firmware-nonfree/88aa085bfa1a4650e1ccd88896f8343c22a24055"; url = "github:RPi-Distro/firmware-nonfree/bookworm";
}; };
rpi-bluez-firmware-src = { rpi-bluez-firmware-src = {
flake = false; flake = false;
url = "github:RPi-Distro/bluez-firmware/d9d4741caba7314d6500f588b1eaa5ab387a4ff5"; url = "github:RPi-Distro/bluez-firmware/bookworm";
}; };
libcamera-apps-src = { rpicam-apps-src = {
flake = false; flake = false;
url = "github:raspberrypi/libcamera-apps/v1.4.4"; url = "github:raspberrypi/rpicam-apps/v1.5.0";
}; };
libcamera-src = { libcamera-src = {
flake = false; flake = false;
url = "github:raspberrypi/libcamera/eb00c13d7c9f937732305d47af5b8ccf895e700f"; # v0.2.0+rpt20240418 url = "github:raspberrypi/libcamera/6ddd79b5bdbedc1f61007aed35391f1559f9e29a"; # v0.3.0+rpt20240617
}; };
libpisp-src = { libpisp-src = {
flake = false; 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; libcamera-overlay = self.overlays.libcamera;
}; };
packages.aarch64-linux = { packages.aarch64-linux = {
linux = pinned.rpi-kernels.latest.kernel; kernels = pinned.rpi-kernels;
firmware = pinned.rpi-kernels.latest.firmware; firmware = pinned.raspberrypifw;
wireless-firmware = pinned.rpi-kernels.latest.wireless-firmware; wireless-firmware = pinned.raspberrypiWirelessFirmware;
uboot-rpi-arm64 = pinned.uboot-rpi-arm64; uboot-rpi-arm64 = pinned.uboot-rpi-arm64;
}; };
}; };

View file

@ -1,5 +1,6 @@
{ u-boot-src { 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-src
, rpi-firmware-nonfree-src , rpi-firmware-nonfree-src
, rpi-bluez-firmware-src , rpi-bluez-firmware-src
@ -7,31 +8,95 @@
}: }:
final: prev: final: prev:
let let
# The version to stick at `pkgs.rpi-kernels.latest' versions = {
latest = "v6_6_28"; 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. # Helpers for building the `pkgs.rpi-kernels' map.
rpi-kernel = { kernel, version, fw, wireless-fw, argsOverride ? null }: rpi-kernel = { version, board }:
let let
new-kernel = prev.linux_rpi4.override { kernel = builtins.getAttr version versions;
argsOverride = { version-slug = builtins.replaceStrings [ "v" "_" ] [ "" "." ] version;
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;
in in
{ {
"v${version-slug}" = { "${version}"."${board}" = (final.buildLinux {
kernel = new-kernel; modDirVersion = version-slug;
firmware = new-fw; version = version-slug;
wireless-firmware = new-wireless-fw; 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 in
{ {
# disable firmware compression so that brcm firmware can be found at # disable firmware compression so that brcm firmware can be found at
@ -40,7 +105,7 @@ in
compressFirmwareZstd = x: x; compressFirmwareZstd = x: x;
# provide generic rpi arm64 u-boot # provide generic rpi arm64 u-boot
uboot_rpi_arm64 = prev.buildUBoot rec { uboot-rpi-arm64 = final.buildUBoot rec {
defconfig = "rpi_arm64_defconfig"; defconfig = "rpi_arm64_defconfig";
extraMeta.platforms = [ "aarch64-linux" ]; extraMeta.platforms = [ "aarch64-linux" ];
filesToInstall = [ "u-boot.bin" ]; filesToInstall = [ "u-boot.bin" ];
@ -61,46 +126,23 @@ in
}; };
# default to latest firmware # default to latest firmware
raspberrypiWirelessFirmware = final.rpi-kernels.latest.wireless-firmware; raspberrypiWirelessFirmware = final.callPackage
raspberrypifw = final.rpi-kernels.latest.firmware; (
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 # rpi kernels and firmware are available at
# `pkgs.rpi-kernels.<VERSION>.{kernel,firmware,wireless-firmware}'. # `pkgs.rpi-kernels.<VERSION>.<BOARD>'.
# #
# For example: `pkgs.rpi-kernels.v5_15_87.kernel' # For example: `pkgs.rpi-kernels.v6_6_31.bcm2712'
rpi-kernels = rpi-kernels [{ rpi-kernels = rpi-kernels (
version = "6.6.28"; final.lib.cartesianProductOfSets # this gets renamed yet again to cartesianProduct in April 19 2024
kernel = rpi-linux-6_6-src; { board = boards; version = (builtins.attrNames versions); }
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}";
};
} }

View file

@ -1,17 +1,17 @@
{ libcamera-apps-src { rpicam-apps-src
, libcamera-src , libcamera-src
, libpisp-src , libpisp-src
, ... , ...
}: }:
final: prev: final: prev:
{ {
# A recent known working version of libcamera-apps # A recent known working version of rpicam-apps
libcamera-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 { libpisp = final.stdenv.mkDerivation {
name = "libpisp"; name = "libpisp";
version = "1.0.3"; version = "1.0.6";
src = libpisp-src; src = libpisp-src;
nativeBuildInputs = with final; [ pkg-config meson ninja ]; nativeBuildInputs = with final; [ pkg-config meson ninja ];
buildInputs = with final; [ nlohmann_json boost ]; buildInputs = with final; [ nlohmann_json boost ];
@ -22,9 +22,29 @@ final: prev:
}; };
libcamera = prev.libcamera.overrideAttrs (old: { libcamera = prev.libcamera.overrideAttrs (old: {
version = "0.1.0"; version = "0.2.0";
src = libcamera-src; 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 = [ ]; 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"
];
}); });
} }

View file

@ -1,9 +1,9 @@
{ bluez-firmware, firmware-nonfree }: { bluez-firmware, firmware-nonfree }:
{ lib, stdenvNoCC, fetchFromGitHub }: { lib, stdenvNoCC }:
stdenvNoCC.mkDerivation { stdenvNoCC.mkDerivation {
pname = "raspberrypi-wireless-firmware"; pname = "raspberrypi-wireless-firmware";
version = "2023-11-15"; version = "2024-02-26";
srcs = [ ]; srcs = [ ];

View file

@ -1,28 +1,12 @@
{ libcamera-apps-src { libcamera-apps-src, lib, pkgs, stdenv }:
, lib
, stdenv
, fetchFromGitHub
, fetchpatch
, meson
, pkg-config
, libjpeg
, libtiff
, libpng
, libcamera
, libepoxy
, boost
, libexif
, ninja
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "libcamera-apps"; pname = "libcamera-apps";
version = "v1.4.1"; version = "v1.5.0";
src = libcamera-apps-src; src = libcamera-apps-src;
nativeBuildInputs = [ meson pkg-config ]; nativeBuildInputs = with pkgs; [ meson pkg-config ];
buildInputs = [ libjpeg libtiff libcamera libepoxy boost libexif libpng ninja ]; buildInputs = with pkgs; [ libjpeg libtiff libcamera libepoxy boost libexif libpng ninja ];
mesonFlags = [ mesonFlags = [
"-Denable_qt=false" "-Denable_qt=false"
"-Denable_opencv=false" "-Denable_opencv=false"

View file

@ -3,12 +3,29 @@
let let
cfg = config.raspberry-pi-nix; cfg = config.raspberry-pi-nix;
version = cfg.kernel-version;
board = cfg.board;
kernel = pkgs.rpi-kernels."${version}"."${board}";
in in
{ {
imports = [ ../sd-image ./config.nix ./i2c.nix ]; imports = [ ../sd-image ./config.nix ./i2c.nix ];
options = with lib; { options = with lib; {
raspberry-pi-nix = { 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 = { pin-inputs = {
enable = mkOption { enable = mkOption {
default = true; default = true;
@ -96,8 +113,8 @@ in
TARGET_FIRMWARE_DIR="${firmware-path}" TARGET_FIRMWARE_DIR="${firmware-path}"
TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays" TARGET_OVERLAYS_DIR="$TARGET_FIRMWARE_DIR/overlays"
TMPFILE="$TARGET_FIRMWARE_DIR/tmp" TMPFILE="$TARGET_FIRMWARE_DIR/tmp"
UBOOT="${pkgs.uboot_rpi_arm64}/u-boot.bin" 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"} SHOULD_UBOOT=${if cfg.uboot.enable then "1" else "0"}
SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot" SRC_FIRMWARE_DIR="${pkgs.raspberrypifw}/share/raspberrypi/boot"
STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf) STARTFILES=("$SRC_FIRMWARE_DIR"/start*.elf)
@ -114,7 +131,7 @@ in
cp "$UBOOT" "$TMPFILE" cp "$UBOOT" "$TMPFILE"
mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/u-boot-rpi-arm64.bin" mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/u-boot-rpi-arm64.bin"
echo "${ echo "${
builtins.toString pkgs.uboot_rpi_arm64 builtins.toString pkgs.uboot-rpi-arm64
}" > "$STATE_DIRECTORY/uboot-version" }" > "$STATE_DIRECTORY/uboot-version"
rm "$STATE_DIRECTORY/uboot-migration-in-progress" rm "$STATE_DIRECTORY/uboot-migration-in-progress"
} }
@ -125,7 +142,7 @@ in
cp "$KERNEL" "$TMPFILE" cp "$KERNEL" "$TMPFILE"
mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/kernel.img" mv -T "$TMPFILE" "$TARGET_FIRMWARE_DIR/kernel.img"
echo "${ echo "${
builtins.toString pkgs.rpi-kernels.latest.kernel builtins.toString kernel
}" > "$STATE_DIRECTORY/kernel-version" }" > "$STATE_DIRECTORY/kernel-version"
rm "$STATE_DIRECTORY/kernel-migration-in-progress" 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") != ${ 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 } ]]; then
migrate_uboot migrate_uboot
fi fi
if [[ "$SHOULD_UBOOT" -ne 1 ]] && [[ ! -f "$STATE_DIRECTORY/kernel-version" || $(< "$STATE_DIRECTORY/kernel-version") != ${ 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 } ]]; then
migrate_kernel migrate_kernel
fi fi
@ -301,10 +318,9 @@ in
"reset-raspberrypi" # required for vl805 firmware to load "reset-raspberrypi" # required for vl805 firmware to load
]; ];
# This pin is not necessary, it would be fine to replace it with # 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. # cache hits for kernel builds though.
kernelPackages = pkgs.linuxPackagesFor pkgs.rpi-kernels.latest.kernel; kernelPackages = pkgs.linuxPackagesFor kernel;
loader = { loader = {
grub.enable = lib.mkDefault false; grub.enable = lib.mkDefault false;
initScript.enable = !cfg.uboot.enable; initScript.enable = !cfg.uboot.enable;

View file

@ -19,13 +19,17 @@
${lib.strings.concatStringsSep " " config.boot.kernelParams} ${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 = populate-kernel =
if config.raspberry-pi-nix.uboot.enable if cfg.uboot.enable
then '' 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 '' else ''
cp "${pkgs.rpi-kernels.latest.kernel}/Image" firmware/kernel.img cp "${kernel}/Image" firmware/kernel.img
cp "${kernel-params}" firmware/cmdline.txt cp "${kernel-params}" firmware/cmdline.txt
''; '';
in in
@ -36,7 +40,7 @@
cp ${config.hardware.raspberry-pi.config-output} firmware/config.txt cp ${config.hardware.raspberry-pi.config-output} firmware/config.txt
''; '';
populateRootCommands = populateRootCommands =
if config.raspberry-pi-nix.uboot.enable if cfg.uboot.enable
then '' then ''
mkdir -p ./files/boot mkdir -p ./files/boot
${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot ${config.boot.loader.generic-extlinux-compatible.populateCmd} -c ${config.system.build.toplevel} -d ./files/boot