diff options
| author | Nicolas Graves <ngraves@ngraves.fr> | 2025-09-08 10:21:39 +0200 |
|---|---|---|
| committer | Hilton Chain <hako@ultrarare.space> | 2025-09-23 21:56:55 +0800 |
| commit | 7a67115e0daafb276574a283ce0d474936cfc3e0 (patch) | |
| tree | 47dc548c14e9a625b7e4532e8f0cdd709b6eeea5 /guix | |
| parent | 017e4bf8642dd8bc5de576ed57eec30c0ff833f0 (diff) | |
import: Add firefox updater.
* guix/import/firefox.scm: Implement basic firefox updater.
Signed-off-by: Hilton Chain <hako@ultrarare.space>
Modified-by: Hilton Chain <hako@ultrarare.space>
Diffstat (limited to 'guix')
| -rw-r--r-- | guix/import/firefox.scm | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/guix/import/firefox.scm b/guix/import/firefox.scm new file mode 100644 index 0000000..7bcaf07 --- /dev/null +++ b/guix/import/firefox.scm | |||
| @@ -0,0 +1,47 @@ | |||
| 1 | ;;; SPDX-License-Identifier: GPL-3.0-or-later | ||
| 2 | ;;; Copyright © 2025 Nicolas Graves <ngraves@ngraves.fr> | ||
| 3 | |||
| 4 | ;;; This file is not part of GNU Guix but requires this naming scheme | ||
| 5 | ;;; so that the %firefox-updater is properly read when using | ||
| 6 | ;;; `guix refresh -L$(pwd) firefox' in nonguix root. | ||
| 7 | |||
| 8 | (define-module (guix import firefox) | ||
| 9 | #:use-module (guix import json) | ||
| 10 | #:use-module (guix memoization) | ||
| 11 | #:use-module (guix packages) | ||
| 12 | #:use-module (guix upstream) | ||
| 13 | #:export (%firefox-updater)) | ||
| 14 | |||
| 15 | (define firefox-json-url "https://product-details.mozilla.org/1.0/firefox_versions.json") | ||
| 16 | |||
| 17 | (define firefox-versions | ||
| 18 | (memoize | ||
| 19 | (lambda _ | ||
| 20 | (let ((alist (json-fetch firefox-json-url))) | ||
| 21 | (list (cons "firefox" (assoc-ref alist "LATEST_FIREFOX_VERSION")) | ||
| 22 | (cons "firefox-esr" (assoc-ref alist "FIREFOX_ESR"))))))) | ||
| 23 | |||
| 24 | (define* (latest-release package #:key (version #f) partial-version?) | ||
| 25 | "Return an <upstream-source> for the latest-release of PACKAGE." | ||
| 26 | (let* ((name (package-name package)) | ||
| 27 | (version (or version (assoc-ref (firefox-versions) name)))) | ||
| 28 | (upstream-source | ||
| 29 | (package name) | ||
| 30 | (version version) | ||
| 31 | (urls | ||
| 32 | (list (string-append "https://archive.mozilla.org/pub/firefox/releases/" | ||
| 33 | version "/source/firefox-" | ||
| 34 | version ".source.tar.xz")))))) | ||
| 35 | |||
| 36 | (define (firefox-package? package) | ||
| 37 | "Return true if PACKAGE is Firefox." | ||
| 38 | (member (package-name package) (list "firefox" "firefox-esr"))) | ||
| 39 | |||
| 40 | (define %firefox-updater | ||
| 41 | (upstream-updater | ||
| 42 | (name 'firefox) | ||
| 43 | (description "Updater for Firefox packages") | ||
| 44 | (pred firefox-package?) | ||
| 45 | (import latest-release))) | ||
| 46 | |||
| 47 | ;;; firefox.scm ends here. | ||
