nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
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 # Fix multiple definition errors by using C++17 instead of C++11
107 substituteInPlace CMakeLists.txt \
108 --replace "set(CMAKE_CXX_STANDARD 11)" "set(CMAKE_CXX_STANDARD 17)"
109 # Fix the build with CMake 4.
110 # See:
111 # * <https://github.com/webmproject/sjpeg/commit/9990bdceb22612a62f1492462ef7423f48154072>
112 # * <https://github.com/webmproject/sjpeg/commit/94e0df6d0f8b44228de5be0ff35efb9f946a13c9>
113 substituteInPlace third_party/sjpeg/CMakeLists.txt \
114 --replace-fail \
115 'cmake_minimum_required(VERSION 2.8.7)' \
116 'cmake_minimum_required(VERSION 3.5...3.10)'
117 '';
118 postInstall = "";
119
120 cmakeFlags = [
121 "-DJPEGXL_FORCE_SYSTEM_BROTLI=ON"
122 "-DJPEGXL_FORCE_SYSTEM_HWY=ON"
123 "-DJPEGXL_FORCE_SYSTEM_GTEST=ON"
124 ]
125 ++ lib.optionals stdenv.hostPlatform.isStatic [
126 "-DJPEGXL_STATIC=ON"
127 ]
128 ++ lib.optionals stdenv.hostPlatform.isAarch32 [
129 "-DJPEGXL_FORCE_NEON=ON"
130 ];
131 }
132 );
133 webkit-linux = stdenv.mkDerivation {
134 name = "playwright-webkit";
135 src = fetchzip {
136 url = "https://playwright.azureedge.net/builds/webkit/${revision}/webkit-${suffix'}.zip";
137 stripRoot = false;
138 hash =
139 {
140 x86_64-linux = "sha256-wSMObGeDoy1vW7TO20wL3vWOSpcDgFciK00SqZ15EjM=";
141 aarch64-linux = "sha256-IyZNAcAUxDpCgc/I2dWtIoRqKiZJ1ggmYqqdvUKg6IE=";
142 }
143 .${system} or throwSystem;
144 };
145
146 nativeBuildInputs = [
147 autoPatchelfHook
148 patchelfUnstable
149 makeWrapper
150 ];
151 buildInputs = [
152 at-spi2-atk
153 cairo
154 flite
155 fontconfig.lib
156 freetype
157 glib
158 brotli
159 libjxl'
160 gst_all_1.gst-plugins-bad
161 gst_all_1.gst-plugins-base
162 gst_all_1.gstreamer
163 harfbuzz
164 harfbuzzFull
165 icu70
166 lcms
167 libavif'
168 libdrm
169 libepoxy
170 libevent
171 libgcc.lib
172 libgcrypt
173 libgpg-error
174 libjpeg8
175 libopus
176 libpng
177 libsoup_3
178 libtasn1
179 libwebp
180 libwpe
181 libwpe-fdo
182 libvpx'
183 libxml2
184 libxslt
185 libgbm
186 sqlite
187 systemdLibs
188 wayland-scanner
189 woff2.lib
190 libxkbcommon
191 zlib
192 ];
193
194 patchelfFlags = [ "--no-clobber-old-sections" ];
195 buildPhase = ''
196 cp -R . $out
197
198 # remove unused gtk browser
199 rm -rf $out/minibrowser-gtk
200 # remove bundled libs
201 rm -rf $out/minibrowser-wpe/sys
202
203 # TODO: still fails on ubuntu trying to find libEGL_mesa.so.0
204 wrapProgram $out/minibrowser-wpe/bin/MiniBrowser \
205 --prefix GIO_EXTRA_MODULES ":" "${glib-networking}/lib/gio/modules/" \
206 --prefix LD_LIBRARY_PATH ":" $out/minibrowser-wpe/lib
207
208 '';
209
210 preFixup = ''
211 # Fix libxml2 breakage. See https://github.com/NixOS/nixpkgs/pull/396195#issuecomment-2881757108
212 mkdir -p "$out/lib"
213 ln -s "${lib.getLib libxml2}/lib/libxml2.so" "$out/lib/libxml2.so.2"
214 '';
215 };
216 webkit-darwin = fetchzip {
217 url = "https://playwright.azureedge.net/builds/webkit/${revision}/webkit-${suffix'}.zip";
218 stripRoot = false;
219 hash =
220 {
221 x86_64-darwin = "sha256-a8NKlNhKPEhtWREAgNosvTLE+zphmKYW+CtvW5jwFlQ=";
222 aarch64-darwin = "sha256-DvVTVAxuh4we2278xZFBomFAxcuqyEOCK7mPg3rnYpU=";
223 }
224 .${system} or throwSystem;
225 };
226in
227{
228 x86_64-linux = webkit-linux;
229 aarch64-linux = webkit-linux;
230 x86_64-darwin = webkit-darwin;
231 aarch64-darwin = webkit-darwin;
232}
233.${system} or throwSystem