1{ stdenv
2, fetchgit
3, fetchpatch
4, lib
5, meson
6, ninja
7, pkg-config
8, makeFontsConf
9, openssl
10, libdrm
11, libevent
12, libyaml
13, lttng-ust
14, gst_all_1
15, gtest
16, graphviz
17, doxygen
18, python3
19, python3Packages
20, systemd # for libudev
21}:
22
23stdenv.mkDerivation rec {
24 pname = "libcamera";
25 version = "0.0.5";
26
27 src = fetchgit {
28 url = "https://git.libcamera.org/libcamera/libcamera.git";
29 rev = "v${version}";
30 hash = "sha256-rd1YIEosg4+H/FJBYCoxdQlV9F0evU5fckHJrSdVPOE=";
31 };
32
33 outputs = [ "out" "dev" "doc" ];
34
35 patches = [
36 (fetchpatch {
37 # https://git.libcamera.org/libcamera/libcamera.git/commit/?id=6cb92b523bd60bd7718df134cc5b1eff51cf42e5
38 name = "libcamera-sphinx7.0-compat.patch";
39 url = "https://git.libcamera.org/libcamera/libcamera.git/patch/?id=6cb92b523bd60bd7718df134cc5b1eff51cf42e5";
40 hash = "sha256-gs0EiT3gWlmRjDim+o2C0VmnoWqEouP5pNTD4XbNSdE=";
41 })
42 ];
43
44 postPatch = ''
45 patchShebangs utils/
46 '';
47
48 strictDeps = true;
49
50 buildInputs = [
51 # IPA and signing
52 openssl
53
54 # gstreamer integration
55 gst_all_1.gstreamer
56 gst_all_1.gst-plugins-base
57
58 # cam integration
59 libevent
60 libdrm
61
62 # hotplugging
63 systemd
64
65 # lttng tracing
66 lttng-ust
67
68 # yamlparser
69 libyaml
70
71 gtest
72 ];
73
74 nativeBuildInputs = [
75 meson
76 ninja
77 pkg-config
78 python3
79 python3Packages.jinja2
80 python3Packages.pyyaml
81 python3Packages.ply
82 python3Packages.sphinx
83 graphviz
84 doxygen
85 openssl
86 ];
87
88 mesonFlags = [
89 "-Dv4l2=true"
90 "-Dqcam=disabled"
91 "-Dlc-compliance=disabled" # tries unconditionally to download gtest when enabled
92 # Avoid blanket -Werror to evade build failures on less
93 # tested compilers.
94 "-Dwerror=false"
95 ];
96
97 # Fixes error on a deprecated declaration
98 env.NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
99
100 # Silence fontconfig warnings about missing config
101 FONTCONFIG_FILE = makeFontsConf { fontDirectories = []; };
102
103 # libcamera signs the IPA module libraries at install time, but they are then
104 # modified by stripping and RPATH fixup. Therefore, we need to generate the
105 # signatures again ourselves.
106 #
107 # If this is not done, libcamera will still try to load them, but it will
108 # isolate them in separate processes, which can cause crashes for IPA modules
109 # that are not designed for this (notably ipa_rpi.so).
110 postFixup = ''
111 ../src/ipa/ipa-sign-install.sh src/ipa-priv-key.pem $out/lib/libcamera/ipa_*.so
112 '';
113
114 meta = with lib; {
115 description = "An open source camera stack and framework for Linux, Android, and ChromeOS";
116 homepage = "https://libcamera.org";
117 license = licenses.lgpl2Plus;
118 maintainers = with maintainers; [ citadelcore ];
119 };
120}