1{ stdenv, lib, fetchurl, pkg-config, perl
2, argp-standalone, libjpeg, udev
3, withUtils ? true
4, withGUI ? true, alsa-lib, libX11, qtbase, libGLU, wrapQtAppsHook
5}:
6
7# See libv4l in all-packages.nix for the libs only (overrides alsa, libX11 & QT)
8
9let
10 withQt = withUtils && withGUI;
11
12# we need to use stdenv.mkDerivation in order not to pollute the libv4l’s closure with Qt
13in stdenv.mkDerivation rec {
14 pname = "v4l-utils";
15 version = "1.24.1";
16
17 src = fetchurl {
18 url = "https://linuxtv.org/downloads/${pname}/${pname}-${version}.tar.bz2";
19 hash = "sha256-y7f+imMH9c5TOgXN7XC7k8O6BjlaubbQB+tTt12AX1s=";
20 };
21
22 outputs = [ "out" ] ++ lib.optional withUtils "lib" ++ [ "dev" ];
23
24 configureFlags = (if withUtils then [
25 "--with-localedir=${placeholder "lib"}/share/locale"
26 "--with-udevdir=${placeholder "out"}/lib/udev"
27 ] else [
28 "--disable-v4l-utils"
29 ]);
30
31 postFixup = ''
32 # Create symlink for V4l1 compatibility
33 ln -s "$dev/include/libv4l1-videodev.h" "$dev/include/videodev.h"
34 '';
35
36 nativeBuildInputs = [ pkg-config perl ] ++ lib.optional withQt wrapQtAppsHook;
37
38 buildInputs = [ udev ]
39 ++ lib.optional (!stdenv.hostPlatform.isGnu) argp-standalone
40 ++ lib.optionals withQt [ alsa-lib libX11 qtbase libGLU ];
41
42 propagatedBuildInputs = [ libjpeg ];
43
44 postPatch = ''
45 patchShebangs utils/
46 '';
47
48 enableParallelBuilding = true;
49
50 meta = with lib; {
51 description = "V4L utils and libv4l, provide common image formats regardless of the v4l device";
52 homepage = "https://linuxtv.org/projects.php";
53 changelog = "https://git.linuxtv.org/v4l-utils.git/plain/ChangeLog?h=v4l-utils-${version}";
54 license = with licenses; [ lgpl21Plus gpl2Plus ];
55 maintainers = with maintainers; [ codyopel ];
56 platforms = platforms.linux;
57 };
58}