From 2ba99b1f529cdca434dc0d76c5059d89744e3ee5 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Thu, 8 May 2025 16:22:31 +0000
Subject: [PATCH 1/4] deps: bump puppeteer-core

---
 package-lock.json | 22 +++++++++++-----------
 package.json      |  2 +-
 pkgs/npm-deps.nix |  2 +-
 setup.sh          |  7 ++++---
 4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/package-lock.json b/package-lock.json
index 3df7602..502b6ac 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5,14 +5,14 @@
   "packages": {
     "": {
       "dependencies": {
-        "puppeteer-core": "^24.8.1",
+        "puppeteer-core": "^24.8.2",
         "ws": "^8.18.2"
       }
     },
     "node_modules/@puppeteer/browsers": {
-      "version": "2.10.3",
-      "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.10.3.tgz",
-      "integrity": "sha512-iPpnFpX25gKIVsHsqVjHV+/GzW36xPgsscWkCnrrETndcdxNsXLdCrTwhkCJNR/FGWr122dJUBeyV4niz/j3TA==",
+      "version": "2.10.4",
+      "resolved": "https://registry.npmjs.org/@puppeteer/browsers/-/browsers-2.10.4.tgz",
+      "integrity": "sha512-9DxbZx+XGMNdjBynIs4BRSz+M3iRDeB7qRcAr6UORFLphCIM2x3DXgOucvADiifcqCE4XePFUKcnaAMyGbrDlQ==",
       "license": "Apache-2.0",
       "dependencies": {
         "debug": "^4.4.0",
@@ -37,9 +37,9 @@
       "license": "MIT"
     },
     "node_modules/@types/node": {
-      "version": "22.15.12",
-      "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.12.tgz",
-      "integrity": "sha512-K0fpC/ZVeb8G9rm7bH7vI0KAec4XHEhBam616nVJCV51bKzJ6oA3luG4WdKoaztxe70QaNjS/xBmcDLmr4PiGw==",
+      "version": "22.15.17",
+      "resolved": "https://registry.npmjs.org/@types/node/-/node-22.15.17.tgz",
+      "integrity": "sha512-wIX2aSZL5FE+MR0JlvF87BNVrtFWf6AE6rxSE9X7OwnVvoyCQjpzSRJ+M87se/4QCkCiebQAqrJ0y6fwIyi7nw==",
       "license": "MIT",
       "optional": true,
       "dependencies": {
@@ -613,12 +613,12 @@
       }
     },
     "node_modules/puppeteer-core": {
-      "version": "24.8.1",
-      "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.8.1.tgz",
-      "integrity": "sha512-UP/VIxVk/Akrgql3a55ZAIuAIx7+yQevz6qEXFUtSTIynEcgsCJ6tlRdi7uKAAlovmNQG4iNMzq9f8WxZLnGGg==",
+      "version": "24.8.2",
+      "resolved": "https://registry.npmjs.org/puppeteer-core/-/puppeteer-core-24.8.2.tgz",
+      "integrity": "sha512-wNw5cRZOHiFibWc0vdYCYO92QuKTbJ8frXiUfOq/UGJWMqhPoBThTKkV+dJ99YyWfzJ2CfQQ4T1nhhR0h8FlVw==",
       "license": "Apache-2.0",
       "dependencies": {
-        "@puppeteer/browsers": "2.10.3",
+        "@puppeteer/browsers": "2.10.4",
         "chromium-bidi": "5.1.0",
         "debug": "^4.4.0",
         "devtools-protocol": "0.0.1439962",
diff --git a/package.json b/package.json
index 66d6f54..a584ab2 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
   "dependencies": {
-    "puppeteer-core": "^24.8.1",
+    "puppeteer-core": "^24.8.2",
     "ws": "^8.18.2"
   }
 }
diff --git a/pkgs/npm-deps.nix b/pkgs/npm-deps.nix
index c2698fb..fb04dae 100644
--- a/pkgs/npm-deps.nix
+++ b/pkgs/npm-deps.nix
@@ -12,7 +12,7 @@ buildNpmPackage {
     "package.json"
     "package-lock.json"
   ];
-  npmDepsHash = "sha512-vyVsKiTqi9CQpXTYI/9Mght9Tg0HszVSOng8jGX4joz1YmAqbmQNRpQDV70ScDhD/KW8KI1xdEVU3RXzOCQNnw==";
+  npmDepsHash = "sha512-dIrmbHAo0D+aWqgxdXP6IHTRM7ZsTnTPdo8Yns+W7n3zkIxEfqEDotsYALrlKK7Jta8yFu89yyBoJ8ZS7ldNzA==";
 
   dontNpmBuild = true;
   dontNpmInstall = true;
diff --git a/setup.sh b/setup.sh
index 5810adc..a3f4d2b 100755
--- a/setup.sh
+++ b/setup.sh
@@ -111,10 +111,11 @@ mkdir -p "$PREFIX/nodejs"
 curl -f -L --retry 5 "$(jq -r ".\"$NODEJS\".url" "$REPO"/autogen.json)" -o nodejs.tar.xz
 tar xJf nodejs.tar.xz -C "$PREFIX/nodejs" --no-same-owner --strip-components=1
 "$PREFIX/nodejs/bin/node" "$PREFIX/nodejs/bin/npm" install -g --prefix "$PREFIX/nodejs" \
-  puppeteer-core@^24.8.1 \
-  ws@^8.18.2 \
-  playwright@^1.52.0
+  puppeteer-core@^24.8.2 \
+  ws@^8.18.2
 if [[ -n "${PLAYWRIGHT:-}" ]]; then
+  "$PREFIX/nodejs/bin/node" "$PREFIX/nodejs/bin/npm" install -g --prefix "$PREFIX/nodejs" \
+    playwright
   PATH=$PREFIX/nodejs/bin:$PATH playwright install --with-deps
 fi
 
-- 
GitLab


From db0a7d61abc75c8b7e6103d12156d1a6fccaf58d Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Thu, 8 May 2025 16:23:34 +0000
Subject: [PATCH 2/4] ci: probe more flavours of firefox/chrome

---
 tests/ghci.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/ghci.sh b/tests/ghci.sh
index 22993be..1468b98 100755
--- a/tests/ghci.sh
+++ b/tests/ghci.sh
@@ -6,13 +6,13 @@ GHCI_SCRIPT='foreign import javascript "new Promise(res => setTimeout(res, 1024,
 
 echo -e "$GHCI_SCRIPT" | wasm32-wasi-ghc --interactive -package ghc -package Cabal
 
-FIREFOX_PATH=$(type -P firefox || echo "")
+FIREFOX_PATH=$(type -P firefox-esr || type -P firefox || type -P firefox-beta || type -P firefox-devedition || type -P firefox-nightly || echo "")
 
 if [[ $FIREFOX_PATH != "" ]]; then
   echo -e "$GHCI_SCRIPT" | wasm32-wasi-ghc --interactive -fghci-browser -fghci-browser-puppeteer-launch-opts="{\"browser\":\"firefox\",\"executablePath\":\"$FIREFOX_PATH\"}"
 fi
 
-CHROME_PATH=$(type -P google-chrome-stable || type -P chromium || type -P chromium-browser || echo "")
+CHROME_PATH=$(type -P google-chrome-stable || type -P google-chrome-beta || type -P google-chrome-unstable || type -P google-chrome-canary || type -P chromium || type -P chromium-browser || echo "")
 
 if [[ $CHROME_PATH != "" ]]; then
   echo -e "$GHCI_SCRIPT" | wasm32-wasi-ghc --interactive -fghci-browser -fghci-browser-puppeteer-launch-opts="{\"browser\":\"chrome\",\"protocol\":\"webDriverBiDi\",\"executablePath\":\"$CHROME_PATH\",\"args\":[\"--no-sandbox\"]}"
-- 
GitLab


From 37f45202c3e19952379791f1dcd227a5915f4acf Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Thu, 8 May 2025 16:24:42 +0000
Subject: [PATCH 3/4] ci: simplify firefox/chrome installation script

---
 .gitlab-ci.yml | 15 +++++----------
 1 file changed, 5 insertions(+), 10 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index b9d2095..19a88a1 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,24 +27,19 @@ variables:
       sudo apt update
       sudo apt full-upgrade -y
       sudo apt install -y \
-        gnupg \
         zstd
 
-      curl -f -L --retry 5 https://packages.mozilla.org/apt/repo-signing-key.gpg | sudo tee /usr/share/keyrings/packages.mozilla.org.asc
+      curl -f -L https://packages.mozilla.org/apt/repo-signing-key.gpg | sudo tee /usr/share/keyrings/packages.mozilla.org.asc
       echo "deb [signed-by=/usr/share/keyrings/packages.mozilla.org.asc] https://packages.mozilla.org/apt mozilla main" | sudo tee /etc/apt/sources.list.d/mozilla.list
-      echo '
-      Package: *
-      Pin: origin packages.mozilla.org
-      Pin-Priority: 1000
-      ' | sudo tee /etc/apt/preferences.d/mozilla
 
-      curl -f -L --retry 5 https://dl.google.com/linux/linux_signing_key.pub | sudo gpg --dearmor -o /usr/share/keyrings/google-chrome.gpg
-      echo "deb [signed-by=/usr/share/keyrings/google-chrome.gpg] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
+      curl -f -L https://dl.google.com/linux/linux_signing_key.pub | sudo tee /usr/share/keyrings/google.asc
+      echo "deb [signed-by=/usr/share/keyrings/google.asc] http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee /etc/apt/sources.list.d/google-chrome.list
 
       sudo apt update
       sudo apt install -y \
-        firefox \
         google-chrome-stable
+      sudo apt install -y --target-release=mozilla \
+        firefox
     - sudo chown ghc:ghc -R .
     - |
       PREFIX=/tmp/.ghc-wasm ./setup.sh
-- 
GitLab


From 27bcdaf4d886ff146368d525357dab129d80a815 Mon Sep 17 00:00:00 2001
From: Cheng Shao <terrorjack@type.dance>
Date: Sat, 10 May 2025 00:51:33 +0000
Subject: [PATCH 4/4] setup.sh: fix missing --with-haddock=wasm32-wasi-haddock

---
 README.md |  2 +-
 setup.sh  | 28 ++++++++++++++++++++--------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/README.md b/README.md
index f02bbca..16a0952 100644
--- a/README.md
+++ b/README.md
@@ -98,7 +98,7 @@ $ curl https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/bootst
 $ source ~/.ghc-wasm/env
 $ ghcup config add-release-channel https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/raw/master/ghcup-wasm-0.0.9.yaml
 $ ghcup install ghc wasm32-wasi-9.12 -- $CONFIGURE_ARGS
-$ cabal --with-compiler=wasm32-wasi-ghc-9.12 --with-hc-pkg=wasm32-wasi-ghc-pkg-9.12 --with-hsc2hs=wasm32-wasi-hsc2hs-9.12 build
+$ cabal --with-compiler=wasm32-wasi-ghc-9.12 --with-hc-pkg=wasm32-wasi-ghc-pkg-9.12 --with-hsc2hs=wasm32-wasi-hsc2hs-9.12 --with-haddock=wasm32-wasi-haddock-9.12 build
 ```
 
 In case you encounter any issue with `ghcup` based installation,
diff --git a/setup.sh b/setup.sh
index a3f4d2b..d4c3de5 100755
--- a/setup.sh
+++ b/setup.sh
@@ -222,14 +222,26 @@ tar xJf cabal.tar.xz --no-same-owner -C "$PREFIX/cabal/bin" 'cabal'
 mkdir -p "$PREFIX/wasm32-wasi-cabal/bin"
 echo "#!/bin/sh" >> "$PREFIX/wasm32-wasi-cabal/bin/wasm32-wasi-cabal"
 echo 'PREFIX=$(realpath "$(dirname "$0")"/../..)' >> "$PREFIX/wasm32-wasi-cabal/bin/wasm32-wasi-cabal"
-echo \
-  'CABAL_DIR=$PREFIX/.cabal' \
-  'exec' \
-  '$PREFIX/cabal/bin/cabal' \
-  '--with-compiler=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-ghc' \
-  '--with-hc-pkg=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-ghc-pkg' \
-  '--with-hsc2hs=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-hsc2hs' \
-  '${1+"$@"}' >> "$PREFIX/wasm32-wasi-cabal/bin/wasm32-wasi-cabal"
+if [[ "$FLAVOUR" != 9.6 ]] && [[ "$FLAVOUR" != 9.8 ]]; then
+  echo \
+    'CABAL_DIR=$PREFIX/.cabal' \
+    'exec' \
+    '$PREFIX/cabal/bin/cabal' \
+    '--with-compiler=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-ghc' \
+    '--with-hc-pkg=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-ghc-pkg' \
+    '--with-hsc2hs=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-hsc2hs' \
+    '--with-haddock=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-haddock' \
+    '${1+"$@"}' >> "$PREFIX/wasm32-wasi-cabal/bin/wasm32-wasi-cabal"
+else
+  echo \
+    'CABAL_DIR=$PREFIX/.cabal' \
+    'exec' \
+    '$PREFIX/cabal/bin/cabal' \
+    '--with-compiler=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-ghc' \
+    '--with-hc-pkg=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-ghc-pkg' \
+    '--with-hsc2hs=$PREFIX/wasm32-wasi-ghc/bin/wasm32-wasi-hsc2hs' \
+    '${1+"$@"}' >> "$PREFIX/wasm32-wasi-cabal/bin/wasm32-wasi-cabal"
+fi
 chmod 755 "$PREFIX/wasm32-wasi-cabal/bin/wasm32-wasi-cabal"
 
 mkdir "$PREFIX/.cabal"
-- 
GitLab