1{
2 stdenv,
3 lib,
4 fetchFromGitHub,
5 meson,
6 pkg-config,
7 ninja,
8 wayland-scanner,
9 libdrm,
10 minimal ? false,
11 libX11,
12 libXext,
13 libXfixes,
14 wayland,
15 libffi,
16 libGL,
17 mesa,
18 # for passthru.tests
19 intel-compute-runtime,
20 intel-media-driver,
21 mpv,
22 intel-vaapi-driver,
23 vlc,
24 testers,
25}:
26
27stdenv.mkDerivation (finalAttrs: {
28 pname = "libva" + lib.optionalString minimal "-minimal";
29 version = "2.22.0";
30
31 src = fetchFromGitHub {
32 owner = "intel";
33 repo = "libva";
34 rev = finalAttrs.version;
35 sha256 = "sha256-0eOYxyMt2M2lkhoWOhoUQgP/1LYY3QQqSF5TdRUuCbs=";
36 };
37
38 outputs = [
39 "dev"
40 "out"
41 ];
42
43 depsBuildBuild = [ pkg-config ];
44
45 nativeBuildInputs = [
46 meson
47 pkg-config
48 ninja
49 ]
50 ++ lib.optional (!minimal) wayland-scanner;
51
52 buildInputs = [
53 libdrm
54 ]
55 ++ lib.optionals (!minimal) [
56 libX11
57 libXext
58 libXfixes
59 wayland
60 libffi
61 libGL
62 ];
63
64 mesonFlags = lib.optionals stdenv.hostPlatform.isLinux [
65 # Add FHS and Debian paths for non-NixOS applications
66 "-Ddriverdir=${mesa.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/i386-linux-gnu/dri"
67 ];
68
69 env =
70 lib.optionalAttrs (stdenv.cc.bintools.isLLVM && lib.versionAtLeast stdenv.cc.bintools.version "17")
71 {
72 NIX_LDFLAGS = "--undefined-version";
73 }
74 // lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) {
75 NIX_CFLAGS_COMPILE = "-DHAVE_SECURE_GETENV";
76 };
77
78 passthru.tests = {
79 # other drivers depending on libva and selected application users.
80 # Please get a confirmation from the maintainer before adding more applications.
81 inherit
82 intel-compute-runtime
83 intel-media-driver
84 intel-vaapi-driver
85 mpv
86 vlc
87 ;
88 pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
89 };
90
91 meta = with lib; {
92 description = "Implementation for VA-API (Video Acceleration API)";
93 longDescription = ''
94 VA-API is an open-source library and API specification, which provides
95 access to graphics hardware acceleration capabilities for video
96 processing. It consists of a main library (this package) and
97 driver-specific acceleration backends for each supported hardware vendor.
98 '';
99 homepage = "https://01.org/linuxmedia/vaapi";
100 changelog = "https://raw.githubusercontent.com/intel/libva/${finalAttrs.version}/NEWS";
101 license = licenses.mit;
102 maintainers = with maintainers; [ SuperSandro2000 ];
103 pkgConfigModules = [
104 "libva"
105 "libva-drm"
106 ]
107 ++ lib.optionals (!minimal) [
108 "libva-glx"
109 "libva-wayland"
110 "libva-x11"
111 ];
112 platforms = platforms.unix;
113 badPlatforms = [
114 # Mandatory libva shared library.
115 lib.systems.inspect.platformPatterns.isStatic
116 ];
117 };
118})