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