lol
1{ stdenv
2, fetchurl
3, lib
4, pkg-config
5, meson
6, ninja
7, gettext
8, python3
9, gstreamer
10, graphene
11, orc
12, pango
13, libtheora
14, libintl
15, libopus
16, isocodes
17, libjpeg
18, libpng
19, libvisual
20, tremor # provides 'virbisidec'
21, libGL
22, gobject-introspection
23, enableX11 ? stdenv.isLinux
24, libXext
25, libXi
26, libXv
27, enableWayland ? stdenv.isLinux
28, wayland
29, wayland-protocols
30, enableAlsa ? stdenv.isLinux
31, alsa-lib
32# TODO: fix once x86_64-darwin sdk updated
33, enableCocoa ? (stdenv.isDarwin && stdenv.isAarch64)
34, Cocoa
35, OpenGL
36, enableGl ? (enableX11 || enableWayland || enableCocoa)
37, enableCdparanoia ? (!stdenv.isDarwin)
38, cdparanoia
39, glib
40, testers
41# Checks meson.is_cross_build(), so even canExecute isn't enough.
42, enableDocumentation ? stdenv.hostPlatform == stdenv.buildPlatform
43, hotdoc
44}:
45
46stdenv.mkDerivation (finalAttrs: {
47 pname = "gst-plugins-base";
48 version = "1.22.6";
49
50 outputs = [ "out" "dev" ];
51
52 src = let
53 inherit (finalAttrs) pname version;
54 in fetchurl {
55 url = "https://gstreamer.freedesktop.org/src/${pname}/${pname}-${version}.tar.xz";
56 hash = "sha256-UPK00XwC7v5DC776jFzRNLG+eKU8D2DpURNtls9J/Us=";
57 };
58
59 strictDeps = true;
60 depsBuildBuild = [
61 pkg-config
62 ];
63 nativeBuildInputs = [
64 meson
65 ninja
66 pkg-config
67 python3
68 gettext
69 orc
70 glib
71 gstreamer
72 gobject-introspection
73 ] ++ lib.optionals enableDocumentation [
74 hotdoc
75 ] ++ lib.optionals enableWayland [
76 wayland
77 ];
78
79 buildInputs = [
80 graphene
81 orc
82 libtheora
83 libintl
84 libopus
85 isocodes
86 libpng
87 libjpeg
88 tremor
89 pango
90 ] ++ lib.optionals (!stdenv.isDarwin) [
91 libGL
92 libvisual
93 ] ++ lib.optionals stdenv.isDarwin [
94 OpenGL
95 ] ++ lib.optionals enableAlsa [
96 alsa-lib
97 ] ++ lib.optionals enableX11 [
98 libXext
99 libXi
100 libXv
101 ] ++ lib.optionals enableWayland [
102 wayland
103 wayland-protocols
104 ] ++ lib.optional enableCocoa Cocoa
105 ++ lib.optional enableCdparanoia cdparanoia;
106
107 propagatedBuildInputs = [
108 gstreamer
109 ];
110
111 mesonFlags = [
112 "-Dexamples=disabled" # requires many dependencies and probably not useful for our users
113 # See https://github.com/GStreamer/gst-plugins-base/blob/d64a4b7a69c3462851ff4dcfa97cc6f94cd64aef/meson_options.txt#L15 for a list of choices
114 "-Dgl_winsys=${lib.concatStringsSep "," (lib.optional enableX11 "x11" ++ lib.optional enableWayland "wayland" ++ lib.optional enableCocoa "cocoa")}"
115 (lib.mesonEnable "doc" enableDocumentation)
116 ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
117 "-Dtests=disabled"
118 ]
119 ++ lib.optional (!enableX11) "-Dx11=disabled"
120 # TODO How to disable Wayland?
121 ++ lib.optional (!enableGl) "-Dgl=disabled"
122 ++ lib.optional (!enableAlsa) "-Dalsa=disabled"
123 ++ lib.optional (!enableCdparanoia) "-Dcdparanoia=disabled"
124 ++ lib.optionals stdenv.isDarwin [
125 "-Dlibvisual=disabled"
126 ];
127
128 postPatch = ''
129 patchShebangs \
130 scripts/meson-pkg-config-file-fixup.py \
131 scripts/extract-release-date-from-doap-file.py
132 '';
133
134 # This package has some `_("string literal")` string formats
135 # that trip up clang with format security enabled.
136 hardeningDisable = [ "format" ];
137
138 doCheck = false; # fails, wants DRI access for OpenGL
139
140 passthru = {
141 # Downstream `gst-*` packages depending on `gst-plugins-base`
142 # have meson build options like 'gl' etc. that depend
143 # on these features being built in `-base`.
144 # If they are not built here, then the downstream builds
145 # will fail, as they, too, use `-Dauto_features=enabled`
146 # which would enable these options unconditionally.
147 # That means we must communicate to these downstream packages
148 # if the `-base` enabled these options or not, so that
149 # the can enable/disable those features accordingly.
150 # The naming `*Enabled` vs `enable*` is intentional to
151 # distinguish inputs from outputs (what is to be built
152 # vs what was built) and to make them easier to search for.
153 glEnabled = enableGl;
154 waylandEnabled = enableWayland;
155 };
156
157 passthru.tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
158
159 meta = with lib; {
160 description = "Base GStreamer plug-ins and helper libraries";
161 homepage = "https://gstreamer.freedesktop.org";
162 license = licenses.lgpl2Plus;
163 pkgConfigModules = [
164 "gstreamer-audio-1.0"
165 "gstreamer-base-1.0"
166 "gstreamer-net-1.0"
167 "gstreamer-video-1.0"
168 ];
169 platforms = platforms.unix;
170 maintainers = with maintainers; [ matthewbauer lilyinstarlight ];
171 };
172})