1{
2 lib,
3 stdenv,
4 fetchzip,
5 fetchFromGitHub,
6 makeWrapper,
7 autoPatchelfHook,
8 patchelfUnstable,
9 fetchpatch,
10 libjxl,
11 brotli,
12 at-spi2-atk,
13 cairo,
14 flite,
15 fontconfig,
16 freetype,
17 glib,
18 glib-networking,
19 gst_all_1,
20 harfbuzz,
21 harfbuzzFull,
22 icu70,
23 lcms,
24 libavif,
25 libdrm,
26 libepoxy,
27 libevent,
28 libgcc,
29 libgcrypt,
30 libgpg-error,
31 libjpeg8,
32 libopus,
33 libpng,
34 libsoup_3,
35 libtasn1,
36 libvpx,
37 libwebp,
38 libwpe,
39 libwpe-fdo,
40 libxkbcommon,
41 libxml2,
42 libxslt,
43 libgbm,
44 sqlite,
45 systemdLibs,
46 wayland-scanner,
47 woff2,
48 zlib,
49 suffix,
50 revision,
51 system,
52 throwSystem,
53}:
54let
55 suffix' =
56 if lib.hasPrefix "linux" suffix then
57 "ubuntu-22.04" + (lib.removePrefix "linux" suffix)
58 else if lib.hasPrefix "mac" suffix then
59 "mac-14" + (lib.removePrefix "mac" suffix)
60 else
61 suffix;
62 libvpx' = libvpx.overrideAttrs (
63 finalAttrs: previousAttrs: {
64 version = "1.12.0";
65 src = fetchFromGitHub {
66 owner = "webmproject";
67 repo = finalAttrs.pname;
68 rev = "v${finalAttrs.version}";
69 sha256 = "sha256-9SFFE2GfYYMgxp1dpmL3STTU2ea1R5vFKA1L0pZwIvQ=";
70 };
71 }
72 );
73 libavif' = libavif.overrideAttrs (
74 finalAttrs: previousAttrs: {
75 version = "0.9.3";
76 src = fetchFromGitHub {
77 owner = "AOMediaCodec";
78 repo = finalAttrs.pname;
79 rev = "v${finalAttrs.version}";
80 hash = "sha256-ME/mkaHhFeHajTbc7zhg9vtf/8XgkgSRu9I/mlQXnds=";
81 };
82 postPatch = "";
83 patches = [ ];
84 }
85 );
86
87 libjxl' = libjxl.overrideAttrs (
88 finalAttrs: previousAttrs: {
89 version = "0.8.2";
90 src = fetchFromGitHub {
91 owner = "libjxl";
92 repo = "libjxl";
93 rev = "v${finalAttrs.version}";
94 hash = "sha256-I3PGgh0XqRkCFz7lUZ3Q4eU0+0GwaQcVb6t4Pru1kKo=";
95 fetchSubmodules = true;
96 };
97 patches = [
98 # Add missing <atomic> content to fix gcc compilation for RISCV architecture
99 # https://github.com/libjxl/libjxl/pull/2211
100 (fetchpatch {
101 url = "https://github.com/libjxl/libjxl/commit/22d12d74e7bc56b09cfb1973aa89ec8d714fa3fc.patch";
102 hash = "sha256-X4fbYTMS+kHfZRbeGzSdBW5jQKw8UN44FEyFRUtw0qo=";
103 })
104 ];
105 postPatch = "";
106 postInstall = "";
107
108 cmakeFlags =
109 [
110 "-DJPEGXL_FORCE_SYSTEM_BROTLI=ON"
111 "-DJPEGXL_FORCE_SYSTEM_HWY=ON"
112 "-DJPEGXL_FORCE_SYSTEM_GTEST=ON"
113 ]
114 ++ lib.optionals stdenv.hostPlatform.isStatic [
115 "-DJPEGXL_STATIC=ON"
116 ]
117 ++ lib.optionals stdenv.hostPlatform.isAarch32 [
118 "-DJPEGXL_FORCE_NEON=ON"
119 ];
120 }
121 );
122 webkit-linux = stdenv.mkDerivation {
123 name = "playwright-webkit";
124 src = fetchzip {
125 url = "https://playwright.azureedge.net/builds/webkit/${revision}/webkit-${suffix'}.zip";
126 stripRoot = false;
127 hash =
128 {
129 x86_64-linux = "sha256-kGTfPFosn8BsBDo9boJWgkPtdAig8+Ffv3Q4eYPy5ls=";
130 aarch64-linux = "sha256-9NFR3j8M9i3Gk/LCwK+LRpKzJsTt3w2VHGmsGtsoKJU=";
131 }
132 .${system} or throwSystem;
133 };
134
135 nativeBuildInputs = [
136 autoPatchelfHook
137 patchelfUnstable
138 makeWrapper
139 ];
140 buildInputs = [
141 at-spi2-atk
142 cairo
143 flite
144 fontconfig.lib
145 freetype
146 glib
147 brotli
148 libjxl'
149 gst_all_1.gst-plugins-bad
150 gst_all_1.gst-plugins-base
151 gst_all_1.gstreamer
152 harfbuzz
153 harfbuzzFull
154 icu70
155 lcms
156 libavif'
157 libdrm
158 libepoxy
159 libevent
160 libgcc.lib
161 libgcrypt
162 libgpg-error
163 libjpeg8
164 libopus
165 libpng
166 libsoup_3
167 libtasn1
168 libwebp
169 libwpe
170 libwpe-fdo
171 libvpx'
172 libxml2
173 libxslt
174 libgbm
175 sqlite
176 systemdLibs
177 wayland-scanner
178 woff2.lib
179 libxkbcommon
180 zlib
181 ];
182
183 patchelfFlags = [ "--no-clobber-old-sections" ];
184 buildPhase = ''
185 cp -R . $out
186
187 # remove unused gtk browser
188 rm -rf $out/minibrowser-gtk
189 # remove bundled libs
190 rm -rf $out/minibrowser-wpe/sys
191
192 # TODO: still fails on ubuntu trying to find libEGL_mesa.so.0
193 wrapProgram $out/minibrowser-wpe/bin/MiniBrowser \
194 --prefix GIO_EXTRA_MODULES ":" "${glib-networking}/lib/gio/modules/" \
195 --prefix LD_LIBRARY_PATH ":" $out/minibrowser-wpe/lib
196
197 '';
198 };
199 webkit-darwin = fetchzip {
200 url = "https://playwright.azureedge.net/builds/webkit/${revision}/webkit-${suffix'}.zip";
201 stripRoot = false;
202 hash =
203 {
204 x86_64-darwin = "sha256-yvIscuu+37eFH/lEhTPostoJ5kHmpdkZiRBtKWDlOuw=";
205 aarch64-darwin = "sha256-VtOmp/YJ8oRBZvDg4sNskY7TVQdHglwkAveybY7QYno=";
206 }
207 .${system} or throwSystem;
208 };
209in
210{
211 x86_64-linux = webkit-linux;
212 aarch64-linux = webkit-linux;
213 x86_64-darwin = webkit-darwin;
214 aarch64-darwin = webkit-darwin;
215}
216.${system} or throwSystem