btrbk: add mainProgram (#356350)
[NixPkgs.git] / pkgs / by-name / li / libcamera / package.nix
blobf576c74cc824c86be841c81c07cab07ec241ad26
1 { stdenv
2 , fetchgit
3 , lib
4 , meson
5 , ninja
6 , pkg-config
7 , makeFontsConf
8 , openssl
9 , libdrm
10 , libevent
11 , libyaml
12 , gst_all_1
13 , gtest
14 , graphviz
15 , doxygen
16 , python3
17 , python3Packages
18 , systemd # for libudev
19 , withTracing ? lib.meta.availableOn stdenv.hostPlatform lttng-ust
20 , lttng-ust # withTracing
21 , withQcam ? false
22 , qt6 # withQcam
23 , libtiff # withQcam
26 stdenv.mkDerivation rec {
27   pname = "libcamera";
28   version = "0.3.2";
30   src = fetchgit {
31     url = "https://git.libcamera.org/libcamera/libcamera.git";
32     rev = "v${version}";
33     hash = "sha256-rW1BG5blozQKA73P5vH5dGkwQG5JJzxdOU2GCB3xIns=";
34   };
36   outputs = [ "out" "dev" ];
38   postPatch = ''
39     patchShebangs src/py/ utils/
40   '';
42   # libcamera signs the IPA module libraries at install time, but they are then
43   # modified by stripping and RPATH fixup. Therefore, we need to generate the
44   # signatures again ourselves. For reproducibility, we use a static private key.
45   #
46   # If this is not done, libcamera will still try to load them, but it will
47   # isolate them in separate processes, which can cause crashes for IPA modules
48   # that are not designed for this (notably ipa_rpi.so).
49   preBuild = ''
50     ninja src/ipa-priv-key.pem
51     install -D ${./ipa-priv-key.pem} src/ipa-priv-key.pem
52   '';
54   strictDeps = true;
56   buildInputs = [
57     # IPA and signing
58     openssl
60     # gstreamer integration
61     gst_all_1.gstreamer
62     gst_all_1.gst-plugins-base
64     # cam integration
65     libevent
66     libdrm
68     # hotplugging
69     systemd
71     # pycamera
72     python3Packages.pybind11
74     # yamlparser
75     libyaml
77     gtest
78   ] ++ lib.optionals withTracing [ lttng-ust ]
79     ++ lib.optionals withQcam [ libtiff qt6.qtbase qt6.qttools ];
81   nativeBuildInputs = [
82     meson
83     ninja
84     pkg-config
85     python3
86     python3Packages.jinja2
87     python3Packages.pyyaml
88     python3Packages.ply
89     python3Packages.sphinx
90     graphviz
91     doxygen
92     openssl
93   ] ++ lib.optional withQcam qt6.wrapQtAppsHook;
95   mesonFlags = [
96     "-Dv4l2=true"
97     (lib.mesonEnable "tracing" withTracing)
98     (lib.mesonEnable "qcam" withQcam)
99     "-Dlc-compliance=disabled" # tries unconditionally to download gtest when enabled
100     # Avoid blanket -Werror to evade build failures on less
101     # tested compilers.
102     "-Dwerror=false"
103     # Documentation breaks binary compatibility.
104     # Given that upstream also provides public documentation,
105     # we can disable it here.
106     "-Ddocumentation=disabled"
107   ];
109   # Fixes error on a deprecated declaration
110   env.NIX_CFLAGS_COMPILE = "-Wno-error=deprecated-declarations";
112   # Silence fontconfig warnings about missing config
113   FONTCONFIG_FILE = makeFontsConf { fontDirectories = [ ]; };
115   meta = with lib; {
116     description = "Open source camera stack and framework for Linux, Android, and ChromeOS";
117     homepage = "https://libcamera.org";
118     changelog = "https://git.libcamera.org/libcamera/libcamera.git/tag/?h=${src.rev}";
119     license = licenses.lgpl2Plus;
120     maintainers = with maintainers; [ citadelcore ];
121     badPlatforms = [
122       # Mandatory shared libraries.
123       lib.systems.inspect.platformPatterns.isStatic
124     ];
125   };