Subject: [bug#76421] [PATCH v2] gnu: Add mozjs-128

From: André Batista <[email-masked]>
Date: Thu, 20 Feb 2025 15:02:01 -0300

* gnu/packages/gnuzilla.scm (mozjs-128): New variable.

Co-Authored-By: Liliana Marie Prikler <[email-masked]>
Change-Id: I67e8f99c35df30379e9dea3b2ceacda2b4d138de
---
 gnu/packages/gnuzilla.scm | 56 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/gnu/packages/gnuzilla.scm b/gnu/packages/gnuzilla.scm
index 7056dc0b52..b6d194d1bf 100644
--- a/gnu/packages/gnuzilla.scm
+++ b/gnu/packages/gnuzilla.scm
@@ -21,6 +21,8 @@
 ;;; Copyright © 2021 Baptiste Strazzul <[email-masked]>
 ;;; Copyright © 2022 SeerLite <[email-masked]>
 ;;; Copyright © 2024 Aleksandr Vityazev <[email-masked]>
+;;; Copyright © 2025 Liliana Marie Prikler <[email-masked]>
+;;; Copyright © 2025 André Batista <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -231,6 +233,60 @@ (define-public mozjs
 in C/C++.")
     (license license:mpl2.0))) ; and others for some files
 
+(define-public mozjs-128
+  (package
+    (inherit mozjs)
+    (name "mozjs")
+    (version "128.7.0")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://ftp.mozilla.org/pub/firefox"
+                                  "/releases/" version "esr/source/firefox-"
+                                  version "esr.source.tar.xz"))
+              (sha256
+               (base32
+                "1xwl6z8ax3dw5hjb5lwpl5641rmlizmfqs3xg74cnczsvm7bz9z0"))))
+    (inputs (modify-inputs (package-inputs mozjs)
+              (replace "icu4c" icu4c-73)))
+    (native-inputs (modify-inputs (package-native-inputs mozjs)
+                     (append rust-cbindgen)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments mozjs)
+       ((#:phases phases #~%standard-phases)
+         #~(modify-phases #$phases
+             (add-before 'configure 'pre-configure-mozjs-v128
+               ;; These logically belong to two different phases ('configure and
+               ;; 'adjust-tests). Move them to their proper places when this version
+               ;; becomes the main one.
+               (lambda _
+                 ;; Configure script writes to $HOME.
+                 (setenv "HOME" (string-append (getcwd)
+                                               "/" "run-configure-from-here"))
+                 ;; 'adjust-tests
+                 (with-directory-excursion "js/src/tests"
+                   ;; Since 115:
+                   ;; Mismatching array lengths
+                   (delete-file "non262/Intl/supportedValuesOf-timeZones-canonical.js")
+                   ;; FIXME: got "America/Santa_Isabel", expected "America/Tijuana":
+                   ;; America/Santa_Isabel -> America/Tijuana
+                   (delete-file "non262/Intl/DateTimeFormat/timeZone_backward_links.js")
+                   ;; TODO: tzdata 2024a expected – find a way to regenerate
+                   ;; these generated tests
+                   (delete-file "non262/Intl/DateTimeFormat/timeZone_version.js")
+                   ;; FIXME: got "\uD840\uDDF2", expected "\u5047"
+                   (delete-file "non262/Intl/Collator/implicithan.js")
+                   ;; FIXME: got "\uD840\uDDF2", expected "\u3467"
+                   (delete-file "non262/Intl/Collator/big5han-gb2312han.js")
+                   ;; Since 128:
+                   ;; FIXME: got (void 0), expected "GMT"
+                   (delete-file
+                    "non262/Intl/DateTimeFormat/formatRange-timeZoneName-matches-format.js")
+                   ;; FIXME: got 7, expected 9: parts count mismatch
+                   (delete-file
+                    "non262/Intl/DateTimeFormat/formatRange-timeZone-offset.js")
+                   (delete-file
+                    "non262/Intl/DateTimeFormat/formatRange-timeZoneName.js"))))))))))
+
 (define-public mozjs-78
   (package
     (inherit mozjs)

base-commit: 93551174af7a96d61f22f013ad1b9935106bf040
-- 
2.48.1