diff --git a/hardware/rp3.nix b/hardware/rp3.nix index aca3070..2b82dd8 100644 --- a/hardware/rp3.nix +++ b/hardware/rp3.nix @@ -25,10 +25,6 @@ in hardware.enableRedistributableFirmware = true; - environment.systemPackages = with pkgs; [ - libraspberrypi - ]; - services.journald.extraConfig = '' Storage = volatile RuntimeMaxFileSize = 10M diff --git a/modules/camera.nix b/modules/camera.nix index c8a8176..d7d9822 100644 --- a/modules/camera.nix +++ b/modules/camera.nix @@ -1,3 +1,10 @@ -{ config, ... }: +{ config, pkgs, ... }: -{ } +{ + nixpkgs.overlays = [ (import ../overlays/libcamera.nix) ]; + + environment.systemPackages = with pkgs; [ + (callPackage ../rpicam-apps.nix { }) + libcamera + ]; +} diff --git a/overlays/libcamera.nix b/overlays/libcamera.nix new file mode 100644 index 0000000..8c5e606 --- /dev/null +++ b/overlays/libcamera.nix @@ -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 {} + + ''; + }; + }); +} diff --git a/rpicam-apps.nix b/rpicam-apps.nix new file mode 100644 index 0000000..021ed5d --- /dev/null +++ b/rpicam-apps.nix @@ -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; + }; +})