Toggle diff (407 lines)
diff --git a/gnu/packages/librewolf.scm b/gnu/packages/librewolf.scm
index 3e46477724..def21997fc 100644
--- a/gnu/packages/librewolf.scm
+++ b/gnu/packages/librewolf.scm
@@ -94,12 +94,24 @@ (define-module (gnu packages librewolf)
#:use-module (gnu packages xdisorg)
#:use-module (gnu packages xorg))
+;; Define the versions of rust needed to build librewolf, trying to match
+;; upstream. See the file taskcluster/kinds/toolchain/rust.yml at
+;; https://searchfox.org under the particular firefox release, like
+;; mozilla-esr102.
+;; 1.75 is the default in Guix, 1.77 is the minimum for Librewolf.
+(define rust-librewolf rust-1.77)
+
+;; Update this id with every update to its release date.
+;; It's used for cache validation and therefore can lead to strange bugs.
+;; ex: date '+%Y%m%d%H%M%S'
+(define %librewolf-build-id "20240730155826")
+
(define (firefox-source-origin version hash)
(origin
(method url-fetch)
(uri (string-append
"https://ftp.mozilla.org/pub/firefox/releases/"
- version "/source/" "firefox-" version
+ version "/source/firefox-" version
".source.tar.xz"))
(sha256 (base32 hash))))
@@ -115,11 +127,14 @@ (define (librewolf-source-origin version hash)
(define computed-origin-method (@@ (guix packages) computed-origin-method))
-(define librewolf-source
- (let* ((ff-src (firefox-source-origin "126.0.1" "0fr679rcwshwpfxidc55b2xsn4pmrr7p9ix4rr2mv2k7kwsjcc7n"))
- (version "126.0.1-1")
- (lw-src (librewolf-source-origin version "0cac80073vkzd85ai9rbnwixs1h9bpy4dj2ri6jxdlqsy5d663km")))
-
+(define* (make-librewolf-source version #:key firefox-hash librewolf-hash)
+ (let* ((ff-src (firefox-source-origin
+ (car (string-split version #\-))
+ firefox-hash))
+ (version version)
+ (lw-src (librewolf-source-origin
+ version
+ librewolf-hash)))
(origin
(method computed-origin-method)
(file-name (string-append "librewolf-" version ".source.tar.gz"))
@@ -163,11 +178,6 @@ (define librewolf-source
(("^ff_source_tarball:=.*")
(string-append "ff_source_tarball:=" #+ff-src)))
- ;; Remove encoding_rs patch, it doesn't build with Rust 1.75.
- (substitute* '("assets/patches.txt")
- (("patches/encoding_rs.patch\\\n$")
- ""))
-
;; Stage locales.
(begin
(format #t "Staging locales...~%")
@@ -205,526 +215,524 @@ (define librewolf-source
".source.tar.gz")
#$output))))))))
-;; Define the versions of rust needed to build librewolf, trying to match
-;; upstream. See the file taskcluster/ci/toolchain/rust.yml at
-;; https://searchfox.org under the particular firefox release, like
-;; mozilla-esr102.
-(define rust-librewolf rust) ; 1.75 is the default in Guix, 1.65 is the minimum.
-
-;; Update this id with every update to its release date.
-;; It's used for cache validation and therefore can lead to strange bugs.
-;; ex: date '+%Y%m%d%H%M%S'
-(define %librewolf-build-id "20240607212143")
-
(define-public librewolf
- (package
- (name "librewolf")
- (version "126.0.1-1")
- (source librewolf-source)
- (build-system gnu-build-system)
- (arguments
- (list
- #:configure-flags #~(let ((clang #$(this-package-native-input "clang")))
- `("--enable-application=browser"
-
- ;; Configuration
- "--without-wasm-sandboxed-libraries"
- "--with-system-jpeg"
- "--with-system-zlib"
- "--with-system-png"
- "--with-system-webp"
- "--with-system-icu"
- "--with-system-libvpx"
- "--with-system-libevent"
- "--with-system-ffi"
- "--enable-system-pixman"
- "--enable-jemalloc"
-
- ;; see https://bugs.gnu.org/32833
- "--with-system-nspr"
- "--with-system-nss"
-
- ,(string-append "--with-clang-path=" clang
- "/bin/clang")
- ,(string-append "--with-libclang-path=" clang
- "/lib")
-
- ;; Distribution
- "--with-distribution-id=org.guix"
- "--with-app-name=librewolf"
- "--with-app-basename=LibreWolf"
- "--with-branding=browser/branding/librewolf"
-
- ;; Features
- "--disable-tests"
- "--disable-updater"
- "--enable-pulseaudio"
- "--disable-crashreporter"
- "--allow-addon-sideload"
- "--with-unsigned-addon-scopes=app,system"
-
- ;; switch only available on x86, whereas EME
- ;; is not supported on other targets
- ,@(if #$(target-x86?) '("--disable-eme") '())
-
- ;; Build details
- "--disable-debug"
- "--enable-rust-simd"
- "--enable-release"
- "--enable-optimize"
- "--enable-strip"
- "--enable-hardening"
- "--disable-elf-hack"))
- #:imported-modules %cargo-utils-modules
- #:modules `((ice-9 regex)
- (ice-9 string-fun)
- (ice-9 ftw)
- (srfi srfi-1)
- (srfi srfi-26)
- (rnrs bytevectors)
- (rnrs io ports)
- (guix elf)
- (guix build gremlin)
- ,@%gnu-build-system-modules)
- #:phases #~(modify-phases %standard-phases
- (add-after 'unpack 'fix-preferences
- (lambda* (#:key inputs #:allow-other-keys)
- (let ((port (open-file "browser/app/profile/firefox.js"
- "a")))
- (define (write-setting key value)
- (format port "~%pref(\"~a\", ~a);~%" key value)
- (format #t
+ (let ((version "128.0.3-1"))
+ (package
+ (name "librewolf")
+ (version version)
+ (source (make-librewolf-source
+ version
+ #:firefox-hash
+ "1p6ymqzp23xfd4h3lc6aihjbq1ljspli9m17bm6rgklkbk6m8r1j"
+ #:librewolf-hash
+ "0pp36q4rcsiyv9b09jfgfrl1k3vqp5bh08c9iq0r2v8is5rbcdz5"))
+
+ (build-system gnu-build-system)
+ (arguments
+ (list
+ #:configure-flags
+ #~(let ((clang #$(this-package-native-input "clang")))
+ `("--enable-application=browser"
+
+ ;; Configuration
+ "--without-wasm-sandboxed-libraries"
+ "--with-system-jpeg"
+ "--with-system-zlib"
+ "--with-system-png"
+ "--with-system-webp"
+ "--with-system-icu"
+ "--with-system-libvpx"
+ "--with-system-libevent"
+ "--with-system-ffi"
+ "--enable-system-pixman"
+ "--enable-jemalloc"
+
+ ;; see https://bugs.gnu.org/32833
+ "--with-system-nspr"
+ "--with-system-nss"
+
+ ,(string-append "--with-clang-path=" clang
+ "/bin/clang")
+ ,(string-append "--with-libclang-path=" clang
+ "/lib")
+
+ ;; Distribution
+ "--with-distribution-id=org.guix"
+ "--with-app-name=librewolf"
+ "--with-app-basename=LibreWolf"
+ "--with-branding=browser/branding/librewolf"
+
+ ;; Features
+ "--disable-tests"
+ "--disable-updater"
+ "--enable-pulseaudio"
+ "--disable-crashreporter"
+ "--allow-addon-sideload"
+ "--with-unsigned-addon-scopes=app,system"
+ ;; switch only available on x86, whereas EME
+ ;; is not supported on other targets
+ ,@(if #$(target-x86?) '("--disable-eme") '())
+
+ ;; Build details
+ "--disable-debug"
+ "--enable-rust-simd"
+ "--enable-release"
+ "--enable-optimize"
+ "--enable-strip"
+ "--enable-hardening"
+ "--disable-elf-hack"))
+ #:imported-modules %cargo-utils-modules
+ #:modules `((ice-9 regex)
+ (ice-9 string-fun)
+ (ice-9 ftw)
+ (srfi srfi-1)
+ (srfi srfi-26)
+ (rnrs bytevectors)
+ (rnrs io ports)
+ (guix elf)
+ (guix build gremlin)
+ ,@%gnu-build-system-modules)
+ #:phases
+ #~(modify-phases %standard-phases
+ (add-after 'unpack 'fix-preferences
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let ((port (open-file "browser/app/profile/firefox.js"
+ "a")))
+ (define (write-setting key value)
+ (format port "~%pref(\"~a\", ~a);~%" key value)
+ (format #t
"fix-preferences: setting value of ~a to ~a~%" key
value))
- ;; We should allow the sandbox to read the store directory,
- ;; because the sandbox has access to /usr on FHS distros.
- (write-setting
- "security.sandbox.content.read_path_whitelist"
- (string-append "\""
- (%store-directory) "/\""))
-
- ;; XDG settings should be managed by Guix.
- (write-setting "browser.shell.checkDefaultBrowser"
- "false")
- (close-port port))))
- (add-after 'fix-preferences 'fix-ffmpeg-runtime-linker
- (lambda* (#:key inputs #:allow-other-keys)
- (let* ((ffmpeg (assoc-ref inputs "ffmpeg"))
- (libavcodec (string-append ffmpeg
- "/lib/libavcodec.so")))
- ;; Arrange to load libavcodec.so by its absolute file name.
- (substitute* "dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp"
- (("libavcodec\\.so")
- libavcodec)))))
- (add-after 'patch-source-shebangs 'patch-cargo-checksums
- (lambda _
- (use-modules (guix build cargo-utils))
- (let ((null-hash
- ;; This is the SHA256 output of an empty string.
- (string-append
- "e3b0c44298fc1c149afbf4c8996fb924"
- "27ae41e4649b934ca495991b7852b855")))
- (for-each (lambda (file)
- (format #t
+ ;; We should allow the sandbox to read the store directory,
+ ;; because the sandbox has access to /usr on FHS distros.
+ (write-setting
+ "security.sandbox.content.read_path_whitelist"
+ (string-append "\""
+ (%store-directory) "/\""))
+
+ ;; XDG settings should be managed by Guix.
+ (write-setting "browser.shell.checkDefaultBrowser"
+ "false")
+ (close-port port))))
+ (add-after 'fix-preferences 'fix-ffmpeg-runtime-linker
+ (lambda* (#:key inputs #:allow-other-keys)
+ (let* ((ffmpeg (assoc-ref inputs "ffmpeg"))
+ (libavcodec (string-append ffmpeg
+ "/lib/libavcodec.so")))
+ ;; Arrange to load libavcodec.so by its absolute file name.
+ (substitute* "dom/media/platforms/ffmpeg/FFmpegRuntimeLinker.cpp"
+ (("libavcodec\\.so")
+ libavcodec)))))
+ (add-after 'patch-source-shebangs 'patch-cargo-checksums
+ (lambda _
+ (use-modules (guix build cargo-utils))
+ (let ((null-hash
+ ;; This is the SHA256 output of an empty string.
+ (string-append
+ "e3b0c44298fc1c149afbf4c8996fb924"
+ "27ae41e4649b934ca495991b7852b855")))
+ (for-each (lambda (file)
+ (format #t
"patch-cargo-checksums: patching checksums in ~a~%"
file)
- (substitute* file
- (("(checksum = )\".*\"" all name)
- (string-append name "\"" null-hash
- "\""))))
- (find-files "." "Cargo\\.lock$"))
- (for-each generate-all-checksums
- '("build"
- "dom/media"
- "dom/webauthn"
- "gfx"
- "intl"
- "js"
- "media"
- "modules"
- "mozglue/static/rust"
- "netwerk"
- "remote"
- "security/manager/ssl"
- "servo"
- "storage"
- "third_party/rust"
- "toolkit"
- "xpcom/rust"
- "services")))))
- (add-after 'patch-cargo-checksums 'remove-cargo-frozen-flag
- (lambda _
- ;; Remove --frozen flag from cargo invokation, otherwise it'll
- ;; complain that it's not able to change Cargo.lock.
- ;; https://bugzilla.mozilla.org/show_bug.cgi?id=1726373
- (substitute* "build/RunCbindgen.py"
- (("args.append\\(\"--frozen\"\\)") "pass"))))
- (delete 'bootstrap)
- (add-before 'configure 'patch-SpeechDispatcherService.cpp
- (lambda _
- (let* ((lib "libspeechd.so.2")
- (file (string-append
- "dom/media/webspeech/synth/"
- "speechd/SpeechDispatcherService.cpp"))
- (old-content (call-with-input-file file
- get-string-all)))
- (substitute
- file
- `((,(format #f "~s" lib) unquote
- (lambda (line _)
- (string-replace-substring
- line lib
- (string-append #$speech-dispatcher
- "/lib/" lib))))))
- (if (string=? old-content
- (call-with-input-file file
- get-string-all))
- (error
- "substitute did nothing, phase requires an update")))))
- (add-before 'configure 'set-build-id
- ;; Build will write the timestamp to output, which is harmful
- ;; for reproducibility, so change it to a fixed date. Use a
- ;; separate phase for easier modification with inherit.
- (lambda _
- (setenv "MOZ_BUILD_DATE"
- #$%librewolf-build-id)))
- (replace 'configure
- (lambda* (#:key inputs outputs configure-flags
- #:allow-other-keys)
- (setenv "AUTOCONF"
- (string-append (assoc-ref inputs "autoconf")
- "/bin/autoconf"))
- (setenv "SHELL"
- (which "bash"))
- (setenv "CONFIG_SHELL"
- (which "bash"))
- (setenv "MACH_BUILD_PYTHON_NATIVE_PACKAGE_SOURCE"
- "system")
- ;; This should use the host info probably (does it
- ;; build on non-x86_64 though?)
- (setenv "GUIX_PYTHONPATH"
- (string-append (getcwd)
- "/obj-x86_64-pc-linux-gnu/_virtualenvs/build"))
-
- ;; Use Clang, Clang is 2x faster than GCC
- (setenv "AR" "llvm-ar")
- (setenv "NM" "llvm-nm")
- (setenv "CC" "clang")
- (setenv "CXX" "clang++")
- (setenv "MOZ_NOSPAM" "1")
- (setenv "MOZ_APP_NAME" "librewolf")
-
- (setenv "MOZBUILD_STATE_PATH"
- (getcwd))
-
- (let* ((mozconfig (string-append (getcwd) "/mozconfig"))
- (out (assoc-ref outputs "out"))
- (flags (cons (string-append "--prefix=" out)
- configure-flags)))
- (format #t "build directory: ~s~%"
- (getcwd))
- (format #t "configure flags: ~s~%" flags)
-
- (define write-flags
- (lambda flags
- (display (string-join (map (cut string-append
- "ac_add_options " <>)
-