projects/guix·blob javascript-team · refs

410 lines · 15.9 KiB

1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2015 Sou Bunnbu <[email protected]>
3;;; Copyright © 2015 David Hashe <[email protected]>
4;;; Copyright © 2015 Ricardo Wurmus <[email protected]>
5;;; Copyright © 2015–2021 Mark H Weaver <[email protected]>
6;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <[email protected]>
7;;; Copyright © 2018 Pierre Neidhardt <[email protected]>
8;;; Copyright © 2019 Marius Bakke <[email protected]>
9;;; Copyright © 2021, 2022, 2023, 2025 Maxim Cournoyer <[email protected]>
10;;; Copyright © 2022, 2023 Efraim Flashner <[email protected]>
11;;; Copyright © 2024 Abhishek Cherath <[email protected]>
12;;; Copyright © 2025 Juliana Sims <[email protected]>
13;;; Copyright © 2026 Konstantin Suntsov <[email protected]>
14;;;
15;;; This file is part of GNU Guix.
16;;;
17;;; GNU Guix is free software; you can redistribute it and/or modify it
18;;; under the terms of the GNU General Public License as published by
19;;; the Free Software Foundation; either version 3 of the License, or (at
20;;; your option) any later version.
21;;;
22;;; GNU Guix is distributed in the hope that it will be useful, but
23;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25;;; GNU General Public License for more details.
26;;;
27;;; You should have received a copy of the GNU General Public License
28;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29
30(define-module (gnu packages webkit)
31 #:use-module ((guix licenses) #:prefix license:)
32 #:use-module (guix packages)
33 #:use-module (guix download)
34 #:use-module (guix gexp)
35 #:use-module (guix git-download)
36 #:use-module (guix utils)
37 #:use-module (guix build utils)
38 #:use-module (guix build-system cmake)
39 #:use-module (guix build-system meson)
40 #:use-module (gnu packages)
41 #:use-module (gnu packages base)
42 #:use-module (gnu packages bison)
43 #:use-module (gnu packages c)
44 #:use-module (gnu packages compression)
45 #:use-module (gnu packages docbook)
46 #:use-module (gnu packages enchant)
47 #:use-module (gnu packages compiler-tools)
48 #:use-module (gnu packages fontutils)
49 #:use-module (gnu packages freedesktop)
50 #:use-module (gnu packages games)
51 #:use-module (gnu packages gcc)
52 #:use-module (gnu packages gettext)
53 #:use-module (gnu packages ghostscript)
54 #:use-module (gnu packages gl)
55 #:use-module (gnu packages glib)
56 #:use-module (gnu packages gnome)
57 #:use-module (gnu packages gnupg)
58 #:use-module (gnu packages gperf)
59 #:use-module (gnu packages gstreamer)
60 #:use-module (gnu packages gtk)
61 #:use-module (gnu packages icu4c)
62 #:use-module (gnu packages image)
63 #:use-module (gnu packages libreoffice)
64 #:use-module (gnu packages linux)
65 #:use-module (gnu packages llvm)
66 #:use-module (gnu packages perl)
67 #:use-module (gnu packages pkg-config)
68 #:use-module (gnu packages python)
69 #:use-module (gnu packages ruby)
70 #:use-module (gnu packages speech)
71 #:use-module (gnu packages sqlite)
72 #:use-module (gnu packages tls)
73 #:use-module (gnu packages video)
74 #:use-module (gnu packages virtualization)
75 #:use-module (gnu packages xml)
76 #:use-module (gnu packages xdisorg)
77 #:use-module (gnu packages xorg))
78
79(define-public libwpe
80 (package
81 (name "libwpe")
82 (version "1.16.0")
83 (source
84 (origin
85 (method url-fetch)
86 (uri
87 (string-append "https://wpewebkit.org/releases/libwpe-"
88 version ".tar.xz"))
89 (sha256
90 (base32 "0ajb6c7z0lzwgp23pwq7vqly7lmnlbnwrivd906pj1nhng3a7wy7"))))
91 (build-system meson-build-system)
92 (arguments
93 `(#:tests? #f)) ;no tests
94 (native-inputs
95 `(("pkg-config" ,pkg-config)
96 ("python" ,python-wrapper)))
97 (inputs
98 (list mesa))
99 (propagated-inputs
100 (list libxkbcommon))
101 (synopsis "General-purpose library for WPE")
102 (description "LibWPE is general-purpose library specifically developed for
103the WPE-flavored port of WebKit.")
104 (home-page "https://wpewebkit.org/")
105 (license license:bsd-2)))
106
107(define-public wpebackend-fdo
108 (package
109 (name "wpebackend-fdo")
110 (version "1.14.3")
111 (source (origin
112 (method url-fetch)
113 (uri (string-append "https://wpewebkit.org/releases/"
114 "wpebackend-fdo-" version ".tar.xz"))
115 (sha256
116 (base32
117 "0v6wb60m1f628b78dlr2j03xz14r1gdz70iyvf8h51asb511h4hh"))))
118 (build-system meson-build-system)
119 (arguments
120 `(#:tests? #f)) ;no tests
121 (native-inputs
122 (list pkg-config))
123 (inputs
124 (list glib libepoxy libwpe mesa wayland))
125 (home-page "https://wpewebkit.org/")
126 (synopsis "Wayland WPE backend")
127 (description
128 "This package provides a backend implementation for the WPE WebKit
129engine that uses Wayland for graphics output.")
130 (license license:bsd-2)))
131
132(define-public webkitgtk
133 (package
134 (name "webkitgtk")
135 (version "2.50.3")
136 (source (origin
137 (method url-fetch)
138 (uri (string-append "https://www.webkitgtk.org/releases/"
139 "webkitgtk-" version ".tar.xz"))
140 (sha256
141 (base32 "0kymjkskp2ndvs10hvqc0l7i3x19s2hga0g8azhv5djvd6s0d83h"))
142 (patches (search-patches
143 "webkitgtk-adjust-bubblewrap-paths.patch"))))
144 (build-system cmake-build-system)
145 (outputs '("out" "doc"))
146 (arguments
147 (list
148 ;; The release archive doesn't include the resources/sources needed to
149 ;; run the various regression tests.
150 #:tests? #f
151 ;; When building using the default RelWithDebInfo build type, the final
152 ;; binaries require 20 GiB of memory to link (even with ld.gold or lld)
153 ;; and produce 4.6 GiB of debug symbols.
154 #:build-type "Release"
155 #:configure-flags
156 #~(list "-DPORT=GTK"
157 "-DENABLE_INTROSPECTION=ON"
158 "-DUSE_GTK4=ON"
159 ;; Enable WebRTC.
160 "-DENABLE_MEDIA_STREAM=ON"
161 "-DENABLE_WEB_RTC=ON"
162 ;; The minibrowser, not built by default, is a good
163 ;; tool to validate the good operation of
164 ;; webkitgtk.
165 "-DENABLE_MINIBROWSER=ON"
166 "-DUSE_LIBBACKTRACE=OFF" ; XXX: circular dependency
167 "-DUSE_SYSTEM_MALLOC=ON"
168 ;; The default lib installation prefix is lib64.
169 (string-append "-DLIB_INSTALL_DIR=" #$output "/lib")
170 ;; XXX: WebKitGTK makes use of elogind's systemd-compatible
171 ;; headers, which are under the include/elogind prefix. The WTF
172 ;; component doesn't propagate the Journald header correctly
173 ;; detected (stubs from elogind), hence the following hack (see:
174 ;; https://bugs.webkit.org/show_bug.cgi?id=254495).
175 (string-append "-DCMAKE_CXX_FLAGS=-I"
176 (search-input-directory
177 %build-inputs "include/elogind")))
178 ;; The build may fail with -j1 (see:
179 ;; https://bugs.webkit.org/show_bug.cgi?id=195251).
180 #:make-flags #~(list "-j" (number->string (max 2 (parallel-job-count))))
181 #:phases
182 #~(modify-phases %standard-phases
183 (add-before 'build 'set-CC
184 (lambda _
185 ;; Some Perl scripts check for the CC environment variable, else
186 ;; use /usr/bin/gcc.
187 (setenv "CC" #$(cc-for-target))))
188 (add-after 'unpack 'configure-bubblewrap-store-directory
189 (lambda _
190 ;; This phase works in tandem with
191 ;; webkitgtk-adjust-bubblewrap-paths.patch and avoids hard
192 ;; coding /gnu/store, for users with other prefixes.
193 (let ((store-directory (%store-directory)))
194 (substitute*
195 "Source/WebKit/UIProcess/Launcher/glib/BubblewrapLauncher.cpp"
196 (("@storedir@") store-directory)
197 ;; This silences GTK locale errors.
198 ;; Unfortunately, simply bind mounting /run/current-system
199 ;; does not work since it leads to weird issues
200 ;; with symlinks that confuse bubblewrap.
201 (("@localedir@") "/run/current-system/locale")))))
202 (add-after 'unpack 'do-not-disable-new-dtags
203 ;; Ensure the linker uses new dynamic tags as this is what Guix
204 ;; uses and validates in the validate-runpath phase.
205 (lambda _
206 (substitute* "Source/cmake/OptionsCommon.cmake"
207 (("if \\(LD_SUPPORTS_DISABLE_NEW_DTAGS\\)")
208 "if (FALSE)"))))
209 (add-after 'unpack 'embed-absolute-wpebackend-reference
210 (lambda* (#:key inputs #:allow-other-keys)
211 (let ((wpebackend-fdo (assoc-ref inputs "wpebackend-fdo")))
212 (substitute* "Source/WebKit/UIProcess/glib/WebProcessPoolGLib.cpp"
213 (("libWPEBackend-fdo-[\\.0-9]+\\.so" all)
214 (search-input-file inputs (string-append "lib/" all)))))))
215 #$@(if (target-x86-32?)
216 ;; Don't include x86intrin.h on i686-linux.
217 '((add-after 'unpack 'fix-headers
218 (lambda _
219 (substitute* "Source/ThirdParty/ANGLE/src/common/platform.h"
220 (("\\|\\| defined\\(__i386__\\)") "")))))
221 '())
222 #$@(if (target-x86-64?)
223 '()
224 '((add-after 'unpack 'disable-sse2
225 (lambda _
226 (substitute* "Source/cmake/WebKitCompilerFlags.cmake"
227 (("WTF_CPU_X86 AND NOT CMAKE_CROSSCOMPILING")
228 "FALSE"))))))
229 (add-after 'install 'move-doc-files
230 (lambda* (#:key outputs #:allow-other-keys)
231 (let ((doc (assoc-ref outputs "doc")))
232 (mkdir-p (string-append doc "/share"))
233 (rename-file (string-append #$output "/share/doc")
234 (string-append doc "/share/doc"))))))))
235 (native-inputs
236 (list bison
237 gettext-minimal
238 `(,glib "bin") ;for glib-mkenums, etc.
239 gobject-introspection
240 gperf
241 perl
242 pkg-config
243 python-wrapper
244 gi-docgen
245 ruby
246 unifdef))
247 (propagated-inputs
248 (list gtk libsoup))
249 (inputs
250 (list at-spi2-core
251 bubblewrap
252 elogind
253 enchant
254 flite
255 geoclue
256 gst-plugins-base
257 gst-plugins-bad-minimal
258 harfbuzz
259 hyphen
260 icu4c
261 lcms
262 libavif
263 libgcrypt
264 libgudev
265 libjpeg-turbo
266 libjxl
267 libmanette
268 libpng
269 libseccomp
270 libsecret
271 libtasn1
272 libwebp
273 libwpe
274 libxcomposite
275 libxml2
276 libxslt
277 libxt
278 mesa
279 openjpeg
280 openssl
281 sqlite
282 sysprof
283 woff2
284 wpebackend-fdo
285 xdg-dbus-proxy))
286 (properties '((timeout . 144000))) ; 40 hours, most notably for aarch64
287 (home-page "https://www.webkitgtk.org/")
288 (synopsis "Web content engine for GTK+")
289 (description "WebKitGTK+ is a full-featured port of the WebKit rendering engine,
290suitable for projects requiring any kind of web integration, from hybrid
291HTML/CSS applications to full-fledged web browsers. WebKitGTK+ video playing
292capabilities can be extended through the use of GStreamer plugins (not
293propagated by default) such as @code{gst-plugins-good} and
294@code{gst-plugins-bad}.")
295 ;; WebKit's JavaScriptCore and WebCore components are available under
296 ;; the GNU LGPL, while the rest is available under a BSD-style license.
297 (license (list license:lgpl2.0
298 license:lgpl2.1+
299 license:bsd-2
300 license:bsd-3))))
301
302(define-public webkitgtk-for-gtk3
303 (package/inherit webkitgtk
304 (name "webkitgtk-for-gtk3")
305 (arguments
306 (substitute-keyword-arguments arguments
307 ((#:configure-flags flags)
308 #~(cons* "-DUSE_GTK4=OFF"
309 (delete "-DUSE_GTK4=ON" #$flags)))))
310 (propagated-inputs
311 (modify-inputs propagated-inputs
312 (replace "gtk" gtk+)))
313 (inputs
314 (modify-inputs inputs
315 (prepend libnotify)))))
316
317;;; Required by e.g. emacs-next-pgtk, emacs-xwidgets, and some other GNOME
318;;; packages for webkit2gtk-4.0. See also the upstream tracker for libsoup 3:
319;;; https://gitlab.gnome.org/GNOME/libsoup/-/issues/218.
320(define-public webkitgtk-with-libsoup2
321 (package/inherit webkitgtk-for-gtk3
322 (name "webkitgtk-with-libsoup2")
323 (arguments (substitute-keyword-arguments arguments
324 ((#:configure-flags flags)
325 #~(cons "-DUSE_SOUP2=ON" #$flags))))
326 (propagated-inputs
327 (modify-inputs propagated-inputs
328 (replace "libsoup" libsoup-minimal-2)))))
329
330(define-public wpewebkit
331 (package
332 (inherit webkitgtk)
333 (name "wpewebkit")
334 (version "2.50.3")
335 (source (origin
336 (inherit (package-source webkitgtk))
337 (uri (string-append "https://wpewebkit.org/releases/"
338 name "-" version ".tar.xz"))
339 (sha256
340 (base32 "0bzv2h25qr7h0r8likdb8g248qvsilf41cj7prf1avghfr1pzjdg"))))
341 (arguments
342 (substitute-keyword-arguments arguments
343 ((#:configure-flags flags)
344 #~(cons "-DPORT=WPE"
345 (delete "-DPORT=GTK" #$flags)))))
346 (inputs (modify-inputs inputs
347 (prepend libinput)))
348 (synopsis "WebKit port optimized for embedded devices")
349 (description "WPE WebKit allows embedders to create simple and performant
350systems based on Web platform technologies. It is designed with hardware
351acceleration in mind, leveraging common 3D graphics APIs for best performance.")
352 (home-page "https://wpewebkit.org/")
353 (properties '((cpe-name . "wpe_webkit")))))
354
355(define-public cog
356 (package
357 (name "cog")
358 (version "0.18.5")
359 (source
360 (origin (method git-fetch)
361 (uri (git-reference
362 (url "https://github.com/Igalia/cog")
363 (commit version)))
364 (file-name (git-file-name name version))
365 (sha256
366 (base32
367 "12r99jai7laxjir5zy46q87hl6mg391mf578lqrb6k2x6fli76zy"))))
368 (build-system meson-build-system)
369 (arguments
370 (list
371 #:configure-flags
372 #~(list "-Ddocumentation=true"
373 "-Dmanpages=true"
374 "-Dplatforms=drm,headless,wayland,gtk4,x11")
375 #:phases
376 #~(modify-phases %standard-phases
377 (add-after 'unpack 'embed-absolute-wpebackend-reference
378 (lambda* (#:key inputs #:allow-other-keys)
379 (for-each
380 (lambda (file)
381 (substitute* file
382 (("libWPEBackend-fdo-[\\.0-9]+\\.so" all)
383 (search-input-file inputs (string-append "lib/" all)))))
384 (list "platform/drm/cog-platform-drm.c"
385 "platform/gtk4/cog-platform-gtk4.c"
386 "platform/headless/cog-platform-headless.c"
387 "platform/wayland/cog-platform-wl.c"
388 "platform/x11/cog-platform-x11.c")))))
389 #:tests? #f)) ;no tests
390 (native-inputs
391 (list gi-docgen
392 gobject-introspection
393 pkg-config))
394 (inputs
395 (list libinput
396 libwpe
397 libxcb
398 libxkbcommon
399 wayland
400 wayland-protocols
401 wpebackend-fdo
402 wpewebkit))
403 (synopsis "Single-window launcher for WPE Webkit")
404 (description
405 "Cog is a small single \"window\" launcher for the WebKit WPE port. It is
406small, provides no user interface of its own, and is suitable to be used as a
407web application container. The \"window\" may be fullscreen or have UI elements
408depending on the WPE backend being used.")
409 (home-page "https://github.com/Igalia/cog")
410 (license license:expat)))