Skip to content
This repository was archived by the owner on Oct 11, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 65 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@ on:
workflow_dispatch:

jobs:
build:
name: build
nix-build:
name: nix-build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:

- name: checkout
Expand All @@ -27,6 +24,69 @@ jobs:
run: |
nix develop --command bash -c "cd frontend && wasm32-wasi-cabal update && exec ./build.sh --debuginfo --low-memory-unused --converge --gufa --flatten --rereloop -Oz"

ghcup-build:
name: ghcup-build
runs-on: ubuntu-latest
steps:

- name: checkout
uses: actions/checkout@v4

- name: ghc-wasm-meta
run: |
pushd "$(mktemp -d)"
curl -f -L --retry 5 https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz | tar xz --strip-components=1
SKIP_GHC=1 ./setup.sh
~/.ghc-wasm/add_to_github_path.sh
popd

- name: wasm32-wasi-ghc
run: |
ghcup config add-release-channel https://raw.githubusercontent.com/haskell/ghcup-metadata/develop/ghcup-cross-0.0.8.yaml
ghcup install ghc --set wasm32-wasi-9.10.0.20240412 -- $CONFIGURE_ARGS

- name: install-sass
run: |
npm install -g sass

- name: build-frontend
run: |
cd frontend
cabal \
--with-compiler=wasm32-wasi-ghc \
--with-hc-pkg=wasm32-wasi-ghc-pkg \
--with-hsc2hs=wasm32-wasi-hsc2hs \
update
./build.sh --debuginfo --low-memory-unused --converge --gufa --flatten --rereloop -Oz

non-nix-build:
name: non-nix-build
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:

- name: checkout
uses: actions/checkout@v4

- name: ghc-wasm-meta
run: |
pushd "$(mktemp -d)"
curl -f -L --retry 5 https://gitlab.haskell.org/ghc/ghc-wasm-meta/-/archive/master/ghc-wasm-meta-master.tar.gz | tar xz --strip-components=1
./setup.sh
~/.ghc-wasm/add_to_github_path.sh
popd

- name: install-sass
run: |
npm install -g sass

- name: build-frontend
run: |
cd frontend
./build.sh --debuginfo --low-memory-unused --converge --gufa --flatten --rereloop -Oz

- name: upload-pages-artifact
uses: actions/upload-pages-artifact@v3
with:
Expand Down
37 changes: 25 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,40 @@ under the hood.

## Building

### With nix

Within the `nix develop` shell:

```sh
cd frontend
npm install
wasm32-wasi-cabal update
./build.sh -Oz
./build.sh
```

The artifacts will be available in `frontend/dist`. The arguments
passed to `build.sh` are redirected to `wasm-opt`, if omitted, a dev
build without `wasm-opt` will be performed.
If you pass additional arguments to `build.sh`, they will be
redirected to `wasm-opt`, otherwise a dev build without `wasm-opt`
will be performed.

The artifacts will be available in `frontend/dist`.

### Without nix

You can set up the toolchain by either:

They can also be built without nix, as long as the following
dependencies are met:
- Using
[`ghc-wasm-meta`](https://gitlab.haskell.org/ghc/ghc-wasm-meta#getting-started-without-nix)
directly to set up ghc head or ghc 9.10
- Using [`ghcup`](https://www.haskell.org/ghcup/guide/#cross-support)
to set up ghc 9.10

- `wasm32-wasi-ghc`/`wasm32-wasi-cabal` (use `ghc-9.10` branch, JSFFI is not
present in `ghc-9.6`/`ghc-9.8`)
- `node` (at least `v21.2.0`)
- `npm`
- `sass`
Then:

```sh
source ~/.ghc-wasm/env
npm install -g sass
cd frontend
./build.sh
```

## Acknowledgements

Expand Down
2 changes: 1 addition & 1 deletion cabal.project
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packages: . hs2048

index-state: 2024-04-15T08:03:57Z
index-state: 2024-04-20T23:09:54Z

if arch(wasm32)
-- https://github.com/haskellari/splitmix/pull/73
Expand Down
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 16 additions & 1 deletion frontend/build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
#!/usr/bin/env bash

set -e

if [[ $PWD != */frontend ]]; then
echo "This script is meant to be run in the frontend directory"
exit 1
fi

if [ $# -eq 0 ]; then
echo "Building for dev"
dev_mode=true
Expand All @@ -13,7 +19,16 @@ rm -rf dist
mkdir dist
cp ./*.html dist/

wasm32-wasi-cabal build ghc-wasm-miso-examples
if command -v wasm32-wasi-cabal &>/dev/null; then
wasm32-wasi-cabal build ghc-wasm-miso-examples
else
cabal \
--with-compiler=wasm32-wasi-ghc \
--with-hc-pkg=wasm32-wasi-ghc-pkg \
--with-hsc2hs=wasm32-wasi-hsc2hs \
build ghc-wasm-miso-examples
fi

hs_wasm_path=$(find .. -name "*.wasm")

"$(wasm32-wasi-ghc --print-libdir)"/post-link.mjs \
Expand Down