nongnu: google-chrome: Parameterize toolkits.

Chrome supports both GTK and QT and the two newest versions of each for
a total of four UI Toolkits. This impacts closure size and requires
building a LOT of unnecessary packages (relevant to
compile-your-own-system people like me and maybe others).

The solution: gate off and parameterize these toolkits. The default is
to build with all toolkits which is the same behavior currently.
This commit is contained in:
Krzysztof Baranowski 2024-06-16 16:15:48 -07:00
parent b2ce94fe65
commit 7e56eeca56

View File

@ -26,9 +26,12 @@
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (nonguix build-system chromium-binary) #:use-module (nonguix build-system chromium-binary)
#:use-module (nonguix licenses) #:use-module (nonguix licenses)
#:use-module (ice-9 string-fun)) #:use-module (ice-9 string-fun)
#:use-module (srfi srfi-26)
#:export (make-google-chrome))
(define-public (make-google-chrome repo version hash) (define* (make-google-chrome repo version hash
#:key (toolkits '(gtk3 gtk4 qt5 qt6)))
(let* ((name (string-append "google-chrome-" repo)) (let* ((name (string-append "google-chrome-" repo))
(appname (if (string=? repo "stable") (appname (if (string=? repo "stable")
"chrome" "chrome"
@ -53,17 +56,22 @@
#~(let ((path (string-append "opt/google/" #$appname "/"))) #~(let ((path (string-append "opt/google/" #$appname "/")))
(map (lambda (file) (map (lambda (file)
(string-append path file)) (string-append path file))
'("chrome" (append
"chrome-sandbox" '("chrome"
"chrome_crashpad_handler" "chrome-sandbox"
"libEGL.so" "chrome_crashpad_handler"
"libGLESv2.so" "libEGL.so"
"liboptimization_guide_internal.so" "libGLESv2.so"
"libqt5_shim.so" "liboptimization_guide_internal.so"
"libqt6_shim.so" "libvk_swiftshader.so"
"libvk_swiftshader.so" "libvulkan.so.1"
"libvulkan.so.1" "WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so")
"WidevineCdm/_platform_specific/linux_x64/libwidevinecdm.so"))) (if (member 'qt5 '#$toolkits)
'("libqt5_shim.so")
'())
(if (member 'qt6 '#$toolkits)
'("libqt6_shim.so")
'()))))
#:install-plan #:install-plan
#~'(("opt/" "/share") #~'(("opt/" "/share")
("usr/share/" "/share")) ("usr/share/" "/share"))
@ -116,38 +124,59 @@
(wrap-program exe (wrap-program exe
'("CHROME_WRAPPER" = (#$appname))))))))) '("CHROME_WRAPPER" = (#$appname)))))))))
(inputs (inputs
(list bzip2 (append
curl (list bzip2
flac curl
font-liberation flac
gdk-pixbuf font-liberation
gtk gdk-pixbuf
harfbuzz harfbuzz
libexif libexif
libglvnd libglvnd
libpng libpng
libva libva
libxscrnsaver libxscrnsaver
opus opus
pciutils pciutils
pipewire pipewire
qtbase-5 snappy
qtbase util-linux
snappy xdg-utils
util-linux wget)
xdg-utils ;; TODO: Currently the chromium binary build system always adds GTK+ as
wget)) ;; an input so gating it here wouldn't do anything.
;; (if (member 'gtk3 toolkits)
;; (list gtk+)
;; '())
(if (member 'gtk4 toolkits)
(list gtk)
'())
(if (member 'qt5 toolkits)
(list qtbase-5)
'())
(if (member 'qt6 toolkits)
(list qtbase)
'())))
(synopsis "Freeware web browser") (synopsis "Freeware web browser")
(supported-systems '("x86_64-linux")) (supported-systems '("x86_64-linux"))
(description "Google Chrome is a cross-platform web browser developed by Google.") (description "Google Chrome is a cross-platform web browser developed by Google.")
(home-page "https://www.google.com/chrome/") (home-page "https://www.google.com/chrome/")
(license (nonfree "https://www.google.com/intl/en/chrome/terms/"))))) (license (nonfree "https://www.google.com/intl/en/chrome/terms/")))))
(define-public make-google-chrome-stable
(cut make-google-chrome "stable" "127.0.6533.99" "0n6dxjzvbc5p4nhpa9f68isgfvs42d59j4argkiga2xqm14qphd4" <...>))
(define-public google-chrome-stable (define-public google-chrome-stable
(make-google-chrome "stable" "127.0.6533.99" "0n6dxjzvbc5p4nhpa9f68isgfvs42d59j4argkiga2xqm14qphd4")) (make-google-chrome-stable))
(define-public make-google-chrome-beta
(cut make-google-chrome "beta" "128.0.6613.27" "1v5p4zvln8yyh4622fla4hdpf5kfxlf1j3ydj8n2i2glb1vmmnrm" <...>))
(define-public google-chrome-beta (define-public google-chrome-beta
(make-google-chrome "beta" "128.0.6613.27" "1v5p4zvln8yyh4622fla4hdpf5kfxlf1j3ydj8n2i2glb1vmmnrm")) (make-google-chrome-beta))
(define-public make-google-chrome-unstable
(cut make-google-chrome "unstable" "129.0.6643.2" "08kc914p5fk1mgn59nvb1qkfndinmzvwk0yzfsc2z4maicg4isqn" <...>))
(define-public google-chrome-unstable (define-public google-chrome-unstable
(make-google-chrome "unstable" "129.0.6643.2" "08kc914p5fk1mgn59nvb1qkfndinmzvwk0yzfsc2z4maicg4isqn")) (make-google-chrome-unstable))