summaryrefslogtreecommitdiffstats
path: root/pkgs/development/libraries/libva/default.nix
blob: f3e996ec48aee67bfd253b30fd12dd8610ae65ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
  stdenv,
  lib,
  fetchFromGitHub,
  meson,
  pkg-config,
  ninja,
  wayland-scanner,
  libdrm,
  minimal ? false,
  libx11,
  libxcb,
  libxext,
  libxfixes,
  wayland,
  libffi,
  libGL,
  mesa,
  # for passthru.tests
  intel-compute-runtime,
  intel-media-driver,
  mpv,
  intel-vaapi-driver,
  vlc,
  testers,
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "libva" + lib.optionalString minimal "-minimal";
  version = "2.24.1";

  src = fetchFromGitHub {
    owner = "intel";
    repo = "libva";
    rev = finalAttrs.version;
    sha256 = "sha256-kgFvqyUlBZApc8D2i3BX6bHkUVNon5bL4asZ9myhQEM=";
  };

  outputs = [
    "dev"
    "out"
  ];

  depsBuildBuild = [ pkg-config ];

  nativeBuildInputs = [
    meson
    pkg-config
    ninja
  ]
  ++ lib.optional (!minimal) wayland-scanner;

  buildInputs = [
    libdrm
  ]
  ++ lib.optionals (!minimal) [
    libx11
    libxcb
    libxext
    libxfixes
    wayland
    libffi
    libGL
  ];

  mesonFlags = lib.optionals stdenv.hostPlatform.isLinux [
    # Add FHS and Debian paths for non-NixOS applications
    "-Ddriverdir=${mesa.driverLink}/lib/dri:/usr/lib/dri:/usr/lib32/dri:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/i386-linux-gnu/dri"
  ];

  env =
    lib.optionalAttrs (stdenv.cc.bintools.isLLVM && lib.versionAtLeast stdenv.cc.bintools.version "17")
      {
        NIX_LDFLAGS = "--undefined-version";
      }
    // lib.optionalAttrs (stdenv.targetPlatform.useLLVM or false) {
      NIX_CFLAGS_COMPILE = "-DHAVE_SECURE_GETENV";
    };

  passthru.tests = {
    # other drivers depending on libva and selected application users.
    # Please get a confirmation from the maintainer before adding more applications.
    inherit
      intel-compute-runtime
      intel-media-driver
      intel-vaapi-driver
      mpv
      vlc
      ;
    pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
  };

  meta = {
    description = "Implementation for VA-API (Video Acceleration API)";
    longDescription = ''
      VA-API is an open-source library and API specification, which provides
      access to graphics hardware acceleration capabilities for video
      processing. It consists of a main library (this package) and
      driver-specific acceleration backends for each supported hardware vendor.
    '';
    homepage = "https://01.org/linuxmedia/vaapi";
    changelog = "https://raw.githubusercontent.com/intel/libva/${finalAttrs.version}/NEWS";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ SuperSandro2000 ];
    pkgConfigModules = [
      "libva"
      "libva-drm"
    ]
    ++ lib.optionals (!minimal) [
      "libva-glx"
      "libva-wayland"
      "libva-x11"
    ];
    platforms = lib.platforms.unix;
    badPlatforms = [
      # Mandatory libva shared library.
      lib.systems.inspect.platformPatterns.isStatic
    ];
  };
})