summaryrefslogtreecommitdiff
path: root/gnu/build
diff options
context:
space:
mode:
authorJosselin Poiret <dev@jpoiret.xyz>2023-12-27 17:18:52 +0100
committerJosselin Poiret <dev@jpoiret.xyz>2023-12-27 17:18:52 +0100
commit93ac4c20bf4b46b2bb9d0d2b9bec0b728b34de87 (patch)
tree5127da76d9949a1010d89f820feb1608f9465541 /gnu/build
parent8f03a51f5cdf4015d22a42e0796aad28f092e40b (diff)
chromium-extension: Compute json at argument evaluation time.
* gnu/build/chromium-extension.scm (make-chromium-extension): Make use of the make-signing-key procedure inside the argument field, making sure that it is not evaluated at file-load time. This would otherwise try to resolve gnutls when we can't guarantee it's defined because of dependency cycles. Change-Id: Ia7b13acfbca475c2df073e9a88fc8bb9264dd968
Diffstat (limited to 'gnu/build')
-rw-r--r--gnu/build/chromium-extension.scm43
1 files changed, 22 insertions, 21 deletions
diff --git a/gnu/build/chromium-extension.scm b/gnu/build/chromium-extension.scm
index 28449a1e1d5..8171c727341 100644
--- a/gnu/build/chromium-extension.scm
+++ b/gnu/build/chromium-extension.scm
@@ -120,12 +120,7 @@ format."
120when installed, will make the extension contained in PKG available as a 120when installed, will make the extension contained in PKG available as a
121Chromium browser extension. PKG-OUTPUT specifies which output of PKG to use." 121Chromium browser extension. PKG-OUTPUT specifies which output of PKG to use."
122 (let* ((name (package-name pkg)) 122 (let* ((name (package-name pkg))
123 (version (package-version pkg)) 123 (version (package-version pkg)))
124 (private-key (make-signing-key name))
125 (public-key (signing-key->public-der private-key))
126 (checksum (file-sha256sum public-key))
127 (crx (make-crx private-key pkg pkg-output))
128 (json (crx->chromium-json crx version)))
129 (package 124 (package
130 (inherit pkg) 125 (inherit pkg)
131 (name (string-append name "-chromium")) 126 (name (string-append name "-chromium"))
@@ -138,18 +133,24 @@ Chromium browser extension. PKG-OUTPUT specifies which output of PKG to use."
138 (arguments 133 (arguments
139 (list #:modules '((guix build utils)) 134 (list #:modules '((guix build utils))
140 #:builder 135 #:builder
141 #~(begin 136 (let*
142 (use-modules (guix build utils)) 137 ((private-key (make-signing-key name))
143 (define (base16-char->chromium-base16 char) 138 (public-key (signing-key->public-der private-key))
144 ;; Translate CHAR, a hexadecimal character, to a Chromium-style 139 (checksum (file-sha256sum public-key))
145 ;; representation using the letters a-p (where a=0, p=15). 140 (crx (make-crx private-key pkg pkg-output))
146 (string-ref "abcdefghijklmnop" 141 (json (crx->chromium-json crx version)))
147 (string-index "0123456789abcdef" char))) 142 #~(begin
148 (let ((file-name (string-map base16-char->chromium-base16 143 (use-modules (guix build utils))
149 (string-take #$checksum 32))) 144 (define (base16-char->chromium-base16 char)
150 (extension-directory 145 ;; Translate CHAR, a hexadecimal character, to a Chromium-style
151 (string-append #$output 146 ;; representation using the letters a-p (where a=0, p=15).
152 "/share/chromium/extensions"))) 147 (string-ref "abcdefghijklmnop"
153 (mkdir-p extension-directory) 148 (string-index "0123456789abcdef" char)))
154 (symlink #$json (string-append extension-directory "/" 149 (let ((file-name (string-map base16-char->chromium-base16
155 file-name ".json"))))))))) 150 (string-take #$checksum 32)))
151 (extension-directory
152 (string-append #$output
153 "/share/chromium/extensions")))
154 (mkdir-p extension-directory)
155 (symlink #$json (string-append extension-directory "/"
156 file-name ".json"))))))))))