Skip to content

Commit 688c190

Browse files
committed
add ghcXX-minimal-ghc-web flavor: wasm + JS backend dev tooling
The wasm and JavaScript backends need a small set of dev-time tools that aren't part of a stock Haskell shell: * nodejs_22 — required for utils/jsffi/post-link.mjs (uses import.meta.filename added in Node 20.11; Ubuntu's apt nodejs is 18.x and silently breaks the post-link step) and for JSFFI host execution at test time * wabt — wasm-objdump for inspecting custom sections (e.g. detecting ghc_wasm_jsffi imports) in wasm modules * wasmtime — pure-WASI runtime, when a wasm module has no JSFFI imports and can run standalone * emscripten — the JavaScript backend's C toolchain (emcc / em++ / emar / emnm / emranlib / emstrip) Currently downstream consumers (e.g. stable-haskell/ghc's wasm cross-compiler CI) bootstrap these per-platform via apt + NodeSource + nix-env + curl installers, plus PATH workarounds for devx scrubbing /usr/bin. Shipping them in the flavor collapses ~70 lines of platform-shell to one `shell:` line in user workflows. Deliberately NOT bundled: wasi-sdk. Its version needs to match the wasm32-wasi-ghc cross-compiler bundle that ghc-wasm-meta (https://gitlab.haskell.org/ghc/ghc-wasm-meta) owns, so keeping that pin in ghc-wasm-meta avoids version drift across two trees. Users still bootstrap wasi-sdk via ghc-wasm-meta for wasm32-wasi builds. Closure cost on aarch64-darwin (paired with the prior trim commit): ghc98-minimal-ghc (current master) : 6.12 GB ghc98-minimal-ghc (after trim PR) : 4.00 GB (-2.12 GB) ghc98-minimal-ghc-web (this commit) : 5.99 GB (+1.99 GB) Net: the web flavor with the full toolchain ends up SMALLER than the current untrimmed minimal-ghc, because the trim commit removed ghc-9.10.3 and emscripten's LLVM/apple-sdk now dedupes against the shell's base nixpkgs pin (no version fragmentation). Comfortably under the 10 GB GitHub Actions per-repo cache cap on both Darwin and Linux (Linux delta is similar magnitude — emscripten + closure-compiler are the heavy hitters on both). Verified inside the patched shell: $ ghc --version # 9.8.4 $ cabal --version # 3.17.0.0 $ happy --version # 2.1.7 $ alex --version # 3.5.4.0 $ git --version # 2.51.2 (gitMinimal) $ node --version # v22.21.1 $ wasm-objdump --version # 1.0.37 $ wasmtime --version # 38.0.3 $ emcc --version # 4.0.12-git All on the expected store paths.
1 parent f683299 commit 688c190

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

‎dynamic.nix‎

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# define a development shell for dynamically linked applications (default)
2-
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true, withIOGFull ? false, withGHCTooling ? false }:
2+
{ self, pkgs, compiler, compiler-nix-name, toolsModule, withHLS ? true, withHlint ? true, withIOG ? true, withIOGFull ? false, withGHCTooling ? false, withWebTooling ? false }:
33
let iog = import ./iog-libs.nix { inherit pkgs; };
44
tool-version-map = (import ./tool-map.nix) self;
55
tool = tool-name: pkgs.pkgsBuildBuild.haskell-nix.tool compiler-nix-name tool-name [(tool-version-map compiler-nix-name tool-name) toolsModule];
@@ -78,6 +78,7 @@ pkgs.mkShell {
7878
+ lib.optionalString withIOG "-iog"
7979
+ lib.optionalString withIOGFull "-full"
8080
+ lib.optionalString withGHCTooling "-ghc"
81+
+ lib.optionalString withWebTooling "-web"
8182
;
8283
in ''
8384
export PS1="\[\033[01;33m\][\w]$\[\033[00m\] "
@@ -154,6 +155,27 @@ pkgs.mkShell {
154155
libffi.dev
155156
]
156157
)
158+
++ optionals withWebTooling (
159+
# Tooling for the wasm and JavaScript backends. wasi-sdk itself is
160+
# deliberately not bundled — its version needs to match the
161+
# wasm32-wasi-ghc cross-compiler bundle, which ghc-wasm-meta owns
162+
# (https://gitlab.haskell.org/ghc/ghc-wasm-meta). Users still bootstrap
163+
# wasi-sdk via ghc-wasm-meta's installer for wasm32-wasi cross-builds.
164+
# What we DO bundle here:
165+
# * nodejs_22 — required for post-link.mjs (uses import.meta.filename
166+
# added in Node 20.11; Ubuntu's apt nodejs is 18.x)
167+
# and for JSFFI host execution
168+
# * wabt — wasm-objdump for inspecting wasm modules
169+
# * wasmtime — pure-WASI runtime (when no JSFFI imports)
170+
# * emscripten — the JavaScript backend's C toolchain (emcc / em++
171+
# / emar / emnm / emranlib / emstrip)
172+
with pkgs; [
173+
nodejs_22
174+
wabt
175+
wasmtime
176+
emscripten
177+
]
178+
)
157179
;
158180

159181
passthru = {

‎flake.nix‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,10 @@
225225
pkgs.lib.nameValuePair "${short-name}-minimal-ghc" (
226226
import ./dynamic.nix (args // { withHLS = false; withHlint = false; withIOG = false; withGHCTooling = true; })
227227
)) (compilers pkgs)
228+
// pkgs.lib.mapAttrs' (short-name: args:
229+
pkgs.lib.nameValuePair "${short-name}-minimal-ghc-web" (
230+
import ./dynamic.nix (args // { withHLS = false; withHlint = false; withIOG = false; withGHCTooling = true; withWebTooling = true; })
231+
)) (compilers pkgs)
228232
// pkgs.lib.mapAttrs' (short-name: args:
229233
pkgs.lib.nameValuePair "${short-name}-static" (
230234
import ./static.nix (args // { withIOG = false; })

0 commit comments

Comments
 (0)