Skip to content

Commit

Permalink
rp3: build libcamera and rpicam-apps from the Raspberry Pi foundation
Browse files Browse the repository at this point in the history
  • Loading branch information
wagdav committed Jul 28, 2024
1 parent 72bb0f0 commit e1994a2
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 6 deletions.
4 changes: 0 additions & 4 deletions hardware/rp3.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ in

hardware.enableRedistributableFirmware = true;

environment.systemPackages = with pkgs; [
libraspberrypi
];

services.journald.extraConfig = ''
Storage = volatile
RuntimeMaxFileSize = 10M
Expand Down
11 changes: 9 additions & 2 deletions modules/camera.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
{ config, ... }:
{ config, pkgs, ... }:

{ }
{
nixpkgs.overlays = [ (import ../overlays/libcamera.nix) ];

environment.systemPackages = with pkgs; [
(callPackage ../rpicam-apps.nix { })
libcamera
];
}
33 changes: 33 additions & 0 deletions overlays/libcamera.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
final: prev: {
libcamera = prev.libcamera.overrideAttrs (old: {
buildInputs = old.buildInputs ++ [ prev.boost prev.nlohmann_json ];
nativeBuildInputs = old.nativeBuildInputs ++ [ prev.python3Packages.pybind11 ];

BOOST_INCLUDEDIR = "${prev.lib.getDev prev.boost}/include";
BOOST_LIBRARYDIR = "${prev.lib.getLib prev.boost}/lib";

postPatch = old.postPatch + ''
patchShebangs src/py/libcamera
'';

src = prev.fetchFromGitHub {
owner = "raspberrypi";
repo = "libcamera";
rev = "6ddd79b5bdbedc1f61007aed35391f1559f9e29a";
sha256 = "eFIiYCsuukPuG6iqHZeKsXQYSuZ+9q5oLNwuJJ+bAhk=";

nativeBuildInputs = [ prev.git ];

postFetch = ''
cd "$out"
export NIX_SSL_CERT_FILE=${prev.cacert}/etc/ssl/certs/ca-bundle.crt
${prev.lib.getExe prev.meson} subprojects download \
libpisp
find subprojects -type d -name .git -prune -execdir rm -r {} +
'';
};
});
}
70 changes: 70 additions & 0 deletions rpicam-apps.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{ stdenv
, fetchFromGitHub
, lib
, meson
, ninja
, pkg-config
, boost
, ffmpeg
, libcamera
, libdrm
, libepoxy
, libexif
, libjpeg
, libpng
, libtiff
, libX11
, qt5
}:

stdenv.mkDerivation (finalAttrs: {
pname = "rpicam-apps";
version = "1.5.0";

src = fetchFromGitHub {
owner = "raspberrypi";
repo = "rpicam-apps";
rev = "v${finalAttrs.version}";
hash = "sha256-s4zJh6r3VhiquO54KWZ78dVCH1BmlphY9zEB9BidNyo=";
};

buildInputs = [
boost
ffmpeg
libcamera
libdrm
libepoxy
libexif
libjpeg
libpng
libtiff
libX11
qt5.qtbase
];

nativeBuildInputs = [
meson
ninja
pkg-config
qt5.wrapQtAppsHook
];

# Meson is no longer able to pick up Boost automatically.
# https://github.com/NixOS/nixpkgs/issues/86131
BOOST_INCLUDEDIR = "${lib.getDev boost}/include";
BOOST_LIBRARYDIR = "${lib.getLib boost}/lib";

mesonFlags = [
"-Denable_hailo=disabled"
# maybe also disabled QT: "-Denable_qt=disabled"
# See all options here: https://github.com/raspberrypi/rpicam-apps/blob/main/meson_options.txt
];

meta = with lib; {
description = "Small suite of libcamera-based apps that aim to copy the functionality of the existing 'raspicam' apps.";
homepage = "https://github.com/raspberrypi/rpicam-apps";
license = licenses.bsd2;
maintainers = with maintainers; [ jpds ];
platforms = platforms.linux;
};
})

0 comments on commit e1994a2

Please sign in to comment.