python312Packages.kneaddata: init at 0.7.7-alpha (#340230)
[NixPkgs.git] / pkgs / development / libraries / qt-6 / modules / qtwebengine.nix
blobc97dd0377981f9f1ba63273d98be26a1e9db61db
1 { qtModule
2 , qtdeclarative
3 , qtwebchannel
4 , qtpositioning
5 , qtwebsockets
6 , buildPackages
7 , bison
8 , coreutils
9 , flex
10 , git
11 , gperf
12 , ninja
13 , pkg-config
14 , python3
15 , which
16 , nodejs
17 , xorg
18 , libXcursor
19 , libXScrnSaver
20 , libXrandr
21 , libXtst
22 , libxshmfence
23 , libXi
24 , cups
25 , fontconfig
26 , freetype
27 , harfbuzz
28 , icu
29 , dbus
30 , libdrm
31 , zlib
32 , minizip
33 , libjpeg
34 , libpng
35 , libtiff
36 , libwebp
37 , libopus
38 , jsoncpp
39 , protobuf
40 , libvpx
41 , srtp
42 , snappy
43 , nss
44 , libevent
45 , openssl
46 , alsa-lib
47 , pulseaudio
48 , libcap
49 , pciutils
50 , systemd
51 , pipewire
52 , gn
53 , ffmpeg
54 , lib
55 , stdenv
56 , glib
57 , libxml2
58 , libxslt
59 , lcms2
60 , libkrb5
61 , mesa
62 , enableProprietaryCodecs ? true
63   # darwin
64 , autoSignDarwinBinariesHook
65 , bootstrap_cmds
66 , cctools
67 , xcbuild
70 qtModule {
71   pname = "qtwebengine";
72   nativeBuildInputs = [
73     bison
74     coreutils
75     flex
76     git
77     gperf
78     ninja
79     pkg-config
80     (python3.withPackages (ps: with ps; [ html5lib ]))
81     which
82     gn
83     nodejs
84   ] ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [
85     autoSignDarwinBinariesHook
86   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
87     bootstrap_cmds
88     cctools
89     xcbuild
90   ];
91   doCheck = true;
92   outputs = [ "out" "dev" ];
94   dontUseGnConfigure = true;
96   # ninja builds some components with -Wno-format,
97   # which cannot be set at the same time as -Wformat-security
98   hardeningDisable = [ "format" ];
100   patches = [
101     # Don't assume /usr/share/X11, and also respect the XKB_CONFIG_ROOT
102     # environment variable, since NixOS relies on it working.
103     # See https://github.com/NixOS/nixpkgs/issues/226484 for more context.
104     ../patches/qtwebengine-xkb-includes.patch
106     ../patches/qtwebengine-link-pulseaudio.patch
108     # Override locales install path so they go to QtWebEngine's $out
109     ../patches/qtwebengine-locales-path.patch
110   ];
112   postPatch = ''
113     # Patch Chromium build tools
114     (
115       cd src/3rdparty/chromium;
117       # Manually fix unsupported shebangs
118       substituteInPlace third_party/harfbuzz-ng/src/src/update-unicode-tables.make \
119         --replace "/usr/bin/env -S make -f" "/usr/bin/make -f" || true
120       substituteInPlace third_party/webgpu-cts/src/tools/run_deno \
121         --replace "/usr/bin/env -S deno" "/usr/bin/deno" || true
122       patchShebangs .
123     )
125     substituteInPlace cmake/Functions.cmake \
126       --replace "/bin/bash" "${buildPackages.bash}/bin/bash"
128     # Patch library paths in sources
129     substituteInPlace src/core/web_engine_library_info.cpp \
130       --replace "QLibraryInfo::path(QLibraryInfo::DataPath)" "\"$out\"" \
131       --replace "QLibraryInfo::path(QLibraryInfo::TranslationsPath)" "\"$out/translations\"" \
132       --replace "QLibraryInfo::path(QLibraryInfo::LibraryExecutablesPath)" "\"$out/libexec\""
133   ''
134   + lib.optionalString stdenv.hostPlatform.isLinux ''
135     sed -i -e '/lib_loader.*Load/s!"\(libudev\.so\)!"${lib.getLib systemd}/lib/\1!' \
136       src/3rdparty/chromium/device/udev_linux/udev?_loader.cc
138     sed -i -e '/libpci_loader.*Load/s!"\(libpci\.so\)!"${pciutils}/lib/\1!' \
139       src/3rdparty/chromium/gpu/config/gpu_info_collector_linux.cc
140   ''
141   + lib.optionalString stdenv.hostPlatform.isDarwin ''
142     substituteInPlace configure.cmake src/gn/CMakeLists.txt \
143       --replace "AppleClang" "Clang"
144     substituteInPlace cmake/Functions.cmake \
145       --replace "/usr/bin/xcrun" "${xcbuild}/bin/xcrun"
146   '';
148   cmakeFlags = [
149     "-DQT_FEATURE_qtpdf_build=ON"
150     "-DQT_FEATURE_qtpdf_widgets_build=ON"
151     "-DQT_FEATURE_qtpdf_quick_build=ON"
152     "-DQT_FEATURE_pdf_v8=ON"
153     "-DQT_FEATURE_pdf_xfa=ON"
154     "-DQT_FEATURE_pdf_xfa_bmp=ON"
155     "-DQT_FEATURE_pdf_xfa_gif=ON"
156     "-DQT_FEATURE_pdf_xfa_png=ON"
157     "-DQT_FEATURE_pdf_xfa_tiff=ON"
158     "-DQT_FEATURE_webengine_system_libevent=ON"
159     "-DQT_FEATURE_webengine_system_ffmpeg=ON"
160     # android only. https://bugreports.qt.io/browse/QTBUG-100293
161     # "-DQT_FEATURE_webengine_native_spellchecker=ON"
162     "-DQT_FEATURE_webengine_sanitizer=ON"
163     "-DQT_FEATURE_webengine_kerberos=ON"
164   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
165     "-DQT_FEATURE_webengine_system_libxml=ON"
166     "-DQT_FEATURE_webengine_webrtc_pipewire=ON"
168     # Appears not to work on some platforms
169     # https://github.com/Homebrew/homebrew-core/issues/104008
170     "-DQT_FEATURE_webengine_system_icu=ON"
171   ] ++ lib.optionals enableProprietaryCodecs [
172     "-DQT_FEATURE_webengine_proprietary_codecs=ON"
173   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
174     "-DCMAKE_OSX_DEPLOYMENT_TARGET=11.0" # Per Qt 6’s deployment target (why doesn’t the hook work?)
175   ];
177   propagatedBuildInputs = [
178     qtdeclarative
179     qtwebchannel
180     qtwebsockets
181     qtpositioning
183     # Image formats
184     libjpeg
185     libpng
186     libtiff
187     libwebp
189     # Video formats
190     srtp
191     libvpx
193     # Audio formats
194     libopus
196     # Text rendering
197     harfbuzz
199     openssl
200     glib
201     libxslt
202     lcms2
204     libevent
205     ffmpeg
206   ] ++ lib.optionals stdenv.hostPlatform.isLinux [
207     dbus
208     zlib
209     minizip
210     snappy
211     nss
212     protobuf
213     jsoncpp
215     icu
216     libxml2
218     # Audio formats
219     alsa-lib
220     pulseaudio
222     # Text rendering
223     fontconfig
224     freetype
226     libcap
227     pciutils
229     # X11 libs
230     xorg.xrandr
231     libXScrnSaver
232     libXcursor
233     libXrandr
234     xorg.libpciaccess
235     libXtst
236     xorg.libXcomposite
237     xorg.libXdamage
238     libdrm
239     xorg.libxkbfile
240     libxshmfence
241     libXi
242     xorg.libXext
244     # Pipewire
245     pipewire
247     libkrb5
248     mesa
249   ];
251   buildInputs = [
252     cups
253   ];
255   requiredSystemFeatures = [ "big-parallel" ];
257   preConfigure = ''
258     export NINJAFLAGS="-j$NIX_BUILD_CORES"
259   '';
261   # Debug info is too big to link with LTO.
262   separateDebugInfo = false;
264   meta = with lib; {
265     description = "Web engine based on the Chromium web browser";
266     platforms = [ "x86_64-darwin" "aarch64-darwin" "aarch64-linux" "armv7a-linux" "armv7l-linux" "x86_64-linux" ];
267     # This build takes a long time; particularly on slow architectures
268     # 1 hour on 32x3.6GHz -> maybe 12 hours on 4x2.4GHz
269     timeout = 24 * 3600;
270   };