summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nongnu/packages/chrome.scm197
1 files changed, 197 insertions, 0 deletions
diff --git a/nongnu/packages/chrome.scm b/nongnu/packages/chrome.scm
new file mode 100644
index 0000000..4e094be
--- /dev/null
+++ b/nongnu/packages/chrome.scm
@@ -0,0 +1,197 @@
1;;; GNU Guix --- Functional package management for GNU
2;;; Copyright © 2022 Giacomo Leidi <goodoldpaul@autistici.org>
3;;; Copyright © 2022 Mathieu Othacehe <m.othacehe@gmail.com>
4;;; Copyright © 2022 Jonathan Brielmaier <jonathan.brielmaier@web.de>
5;;;
6;;; This file is not part of GNU Guix.
7;;;
8;;; GNU Guix is free software; you can redistribute it and/or modify it
9;;; under the terms of the GNU General Public License as published by
10;;; the Free Software Foundation; either version 3 of the License, or (at
11;;; your option) any later version.
12;;;
13;;; GNU Guix is distributed in the hope that it will be useful, but
14;;; WITHOUT ANY WARRANTY; without even the implied warranty of
15;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16;;; GNU General Public License for more details.
17;;;
18;;; You should have received a copy of the GNU General Public License
19;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
20
21(define-module (nongnu packages chrome)
22 #:use-module (gnu packages base)
23 #:use-module (gnu packages compression)
24 #:use-module (gnu packages cups)
25 #:use-module (gnu packages fontutils)
26 #:use-module (gnu packages databases)
27 #:use-module (gnu packages gcc)
28 #:use-module (gnu packages gl)
29 #:use-module (gnu packages glib)
30 #:use-module (gnu packages gnome)
31 #:use-module (gnu packages gtk)
32 #:use-module (gnu packages linux)
33 #:use-module (gnu packages nss)
34 #:use-module (gnu packages xdisorg)
35 #:use-module (gnu packages xml)
36 #:use-module (gnu packages xorg)
37 #:use-module (guix download)
38 #:use-module (guix gexp)
39 #:use-module (guix packages)
40 #:use-module (guix build-system gnu)
41 #:use-module (nonguix build-system binary)
42 #:use-module (nonguix licenses)
43 #:use-module (ice-9 string-fun))
44
45(define-public (make-google-chrome repo version hash)
46 (let* ((name (string-append "google-chrome-" repo))
47 (appname (if (string=? repo "stable")
48 "chrome"
49 (string-replace-substring name "google-" ""))))
50 (package
51 (name name)
52 (version version)
53 (source (origin
54 (method url-fetch)
55 (uri
56 (string-append
57 "https://dl.google.com/linux/chrome/deb/pool/main/g/"
58 name "/" name "_" version "-1_amd64.deb"))
59 (sha256
60 (base32 hash))))
61 (build-system binary-build-system)
62 (arguments
63 (list
64 ;; almost 300MB, faster to download and build from Google servers
65 #:substitutable? #f
66 #:patchelf-plan
67 #~(let ((patchelf-inputs
68 '("alsa-lib" "at-spi2-atk" "at-spi2-core" "atk" "cairo" "cups"
69 "dbus" "expat" "fontconfig-minimal" "gcc" "gdk-pixbuf" "glib"
70 "gtk" "libdrm" "libnotify" "libsecret" "libx11" "libxcb"
71 "libxcomposite" "libxcursor" "libxdamage" "libxext" "libxfixes"
72 "libxi" "libxkbcommon" "libxkbfile" "libxrandr" "libxrender"
73 "libxtst" "mesa" "nspr" "pango" "zlib"))
74 (path (string-append "opt/google/" #$appname "/")))
75 (map (lambda (file)
76 (cons (string-append path file) (list patchelf-inputs)))
77 '("chrome"
78 "chrome-sandbox"
79 "chrome_crashpad_handler"
80 "nacl_helper"
81 "libEGL.so"
82 "libGLESv2.so")))
83 #:install-plan
84 #~'(("opt/" "/share")
85 ("usr/share/" "/share"))
86 #:phases
87 #~(modify-phases %standard-phases
88 (add-after 'unpack 'unpack-deb
89 (lambda* (#:key inputs #:allow-other-keys)
90 (invoke "ar" "x" #$source)
91 (invoke "rm" "-v" "control.tar.xz"
92 "debian-binary"
93 (string-append "google-chrome-" #$repo "_"
94 #$version
95 "-1_amd64.deb"))
96 (invoke "tar" "xf" "data.tar.xz")
97 (invoke "rm" "-vrf" "data.tar.xz" "etc")))
98 (add-before 'install 'patch-assets
99 ;; Many thanks to
100 ;; https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/networking/browsers/google-chrome/default.nix
101 (lambda _
102 (let* ((bin (string-append #$output "/bin"))
103 (share (string-append #$output "/share"))
104 (opt "./opt")
105 (usr/share "./usr/share")
106 (old-exe (string-append "/opt/google/" #$appname "/google-" #$appname))
107 (exe (string-append bin "/google-" #$appname)))
108 ;; This allows us to override CHROME_WRAPPER later.
109 (substitute* (string-append opt "/google/" #$appname "/google-" #$appname)
110 (("CHROME_WRAPPER") "WRAPPER"))
111 (substitute* (string-append usr/share "/applications/google-" #$appname ".desktop")
112 (("^Exec=.*") (string-append "Exec=" exe "\n")))
113 (substitute* (string-append usr/share "/gnome-control-center/default-apps/google-" #$appname ".xml")
114 ((old-exe) exe))
115 (substitute* (string-append usr/share "/menu/google-" #$appname ".menu")
116 (("/opt") share)
117 ((old-exe) exe))
118 #t)))
119 (add-after 'install 'install-wrapper
120 (lambda _
121 (let* ((bin (string-append #$output "/bin"))
122 (exe (string-append bin "/google-" #$appname))
123 (share (string-append #$output "/share"))
124 (chrome-target (string-append share "/google/" #$appname "/google-" #$appname)))
125 (mkdir-p bin)
126 (symlink chrome-target exe)
127 (wrap-program exe
128 `("FONTCONFIG_PATH" ":" prefix
129 (,(string-join
130 (list
131 (string-append #$(this-package-input "fontconfig-minimal") "/etc/fonts")
132 #$output)
133 ":")))
134 `("LD_LIBRARY_PATH" ":" prefix
135 (,(string-join
136 (list
137 (string-append #$(this-package-input "nss") "/lib/nss")
138 (string-append #$(this-package-input "eudev") "/lib")
139 (string-append #$(this-package-input "gcc") "/lib")
140 (string-append #$(this-package-input "mesa") "/lib")
141 (string-append #$(this-package-input "libxkbfile") "/lib")
142 (string-append #$(this-package-input "zlib") "/lib")
143 (string-append #$(this-package-input "libsecret") "/lib")
144 (string-append #$(this-package-input "sqlcipher") "/lib")
145 (string-append #$(this-package-input "libnotify") "/lib")
146 (string-append #$(this-package-input "libdrm") "/lib")
147 (string-append #$(this-package-input "pipewire") "/lib")
148 #$output)
149 ":")))
150 '("CHROME_WRAPPER" = (#$appname)))))))))
151 (native-inputs (list tar))
152 (inputs
153 (list alsa-lib
154 at-spi2-atk
155 at-spi2-core
156 atk
157 cairo
158 cups
159 dbus
160 eudev
161 expat
162 fontconfig
163 `(,gcc "lib")
164 glib
165 gtk
166 libdrm
167 libnotify
168 librsvg
169 libsecret
170 libx11
171 libxcb
172 libxcomposite
173 libxcursor
174 libxdamage
175 libxext
176 libxfixes
177 libxi
178 libxkbcommon
179 libxkbfile
180 libxrandr
181 libxrender
182 libxtst
183 mesa
184 nspr
185 nss
186 pango
187 pipewire-0.3
188 sqlcipher
189 zlib))
190 (synopsis "Freeware web browser")
191 (supported-systems '("x86_64-linux"))
192 (description "Google Chrome is a cross-platform web browser developed by Google.")
193 (home-page "https://www.google.com/chrome/")
194 (license (nonfree "https://www.google.com/intl/en/chrome/terms/")))))
195
196(define-public google-chrome-stable
197 (make-google-chrome "stable" "107.0.5304.68" "1x9svz5s8fm2zhnpzjpqckzfp37hjni3nf3pm63rwnvbd06y48ja"))