From d6134aa0a9aa0e3fd9cb8f1fb342be362cc19789 Mon Sep 17 00:00:00 2001 From: "code@dmj.io" Date: Thu, 1 Oct 2026 07:44:49 -0500 Subject: [PATCH 1/4] Build with MicroHs (mhs) Add an mhs dev shell, taken from the microhs branch of miso, and a 'make mhs' target that builds the app for the browser with mcabal and emscripten: nix develop .#mhs --command bash -c "make mhs" The result is a single public/index.js, served like the other builds with 'make serve'. CI builds it too. --- .github/workflows/main.yml | 3 + .gitignore | 2 + Makefile | 10 ++- README.md | 6 ++ flake.lock | 143 ++++++++++++++++++++++++++++++++++++- flake.nix | 3 + 6 files changed, 165 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1794231..804be02 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -32,6 +32,9 @@ jobs: - name: Clean and GC run: nix develop .#wasm --command bash -c "make" && nix-collect-garbage -d + - name: Build MicroHs using Nix + run: nix develop .#mhs --command bash -c "make mhs" + - name: Build JS using Nix run: nix develop .#ghcjs --command bash -c "make js" diff --git a/.gitignore b/.gitignore index 5f09a61..a78fdf2 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ dist* result public +.mcabal +.emcache diff --git a/Makefile b/Makefile index e5deb8d..7634b35 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,8 @@ all: update build optim js: update-js build-js +mhs: build-mhs + update: wasm32-wasi-cabal update @@ -33,7 +35,7 @@ serve: http-server public clean: - rm -rf dist-newstyle public + rm -rf dist-newstyle dist-mcabal public update-js: cabal update --with-ghc=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg @@ -45,6 +47,12 @@ build-js: cp -rv static public bunx --bun swc ./all.js -o public/index.js +build-mhs: + mcabal --options=-tbrowser build + rm -rf public + cp -rv static public + cp -v ./dist-mcabal/bin/mhs/app public/index.js + ghcup-update: cabal update $(CABAL_ARGS) diff --git a/README.md b/README.md index 7268813..0905457 100644 --- a/README.md +++ b/README.md @@ -100,6 +100,12 @@ $ nix develop .#wasm --command bash -c "make" $ nix develop .#ghcjs --command bash -c "make js" ``` +### Build (MicroHs) + +```bash +$ nix develop .#mhs --command bash -c "make mhs" +``` + ### Serve To host the built application you can call `serve` diff --git a/flake.lock b/flake.lock index f13d9fa..2b10929 100644 --- a/flake.lock +++ b/flake.lock @@ -36,6 +36,42 @@ "type": "github" } }, + "flake-utils_3": { + "inputs": { + "systems": "systems_3" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_4": { + "inputs": { + "systems": "systems_4" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, "ghc-wasm-meta": { "inputs": { "flake-utils": "flake-utils_2", @@ -57,6 +93,27 @@ "type": "gitlab" } }, + "ghc-wasm-meta_2": { + "inputs": { + "flake-utils": "flake-utils_4", + "nixpkgs": "nixpkgs_3" + }, + "locked": { + "host": "gitlab.haskell.org", + "lastModified": 1789039765, + "narHash": "sha256-XzoDVK/1hsI+VUf5tPyhhzfZKfXTzm4hCrrHwCLz9AI=", + "owner": "haskell-wasm", + "repo": "ghc-wasm-meta", + "rev": "358ea50b8496a69da6ce375c0c58bc049dbcb92d", + "type": "gitlab" + }, + "original": { + "host": "gitlab.haskell.org", + "owner": "haskell-wasm", + "repo": "ghc-wasm-meta", + "type": "gitlab" + } + }, "miso": { "inputs": { "flake-utils": "flake-utils", @@ -77,6 +134,27 @@ "type": "github" } }, + "miso-mhs": { + "inputs": { + "flake-utils": "flake-utils_3", + "ghc-wasm-meta": "ghc-wasm-meta_2", + "nixpkgs": "nixpkgs_4" + }, + "locked": { + "lastModified": 1790810291, + "narHash": "sha256-hH4cTxZwWcaNK3qaZO3tRMhwcDggmSiLwDKmqEx9ld0=", + "owner": "dmjio", + "repo": "miso", + "rev": "91fa9e576a925e22a35838f2a86b1fedf6698b1d", + "type": "github" + }, + "original": { + "owner": "dmjio", + "ref": "microhs", + "repo": "miso", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1774399958, @@ -109,9 +187,42 @@ "type": "github" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1789009968, + "narHash": "sha256-GB16oaxpsrnGNnGIE+0uYBqMRzB9X6FYDUvjvnJAYew=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d58a46e3bc02d91ebe04667f8397752a749c0024", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-26.05-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_4": { + "locked": { + "lastModified": 1788881743, + "narHash": "sha256-2V9GZGvPfrNzxFozhI9dcqV+c3QdA8YZrvAAzqEB+dI=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d6524aaca2ff07876657ae2b323f24be4874944b", + "type": "github" + }, + "original": { + "owner": "nixos", + "repo": "nixpkgs", + "rev": "d6524aaca2ff07876657ae2b323f24be4874944b", + "type": "github" + } + }, "root": { "inputs": { - "miso": "miso" + "miso": "miso", + "miso-mhs": "miso-mhs" } }, "systems": { @@ -143,6 +254,36 @@ "repo": "default", "type": "github" } + }, + "systems_3": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_4": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index c0d06d9..0850c61 100644 --- a/flake.nix +++ b/flake.nix @@ -2,6 +2,8 @@ inputs = { miso.url = "github:dmjio/miso"; + # MicroHs (mhs) support lives on miso's microhs branch for now + miso-mhs.url = "github:dmjio/miso/microhs"; }; outputs = inputs: @@ -10,6 +12,7 @@ devShells.hls = inputs.miso.outputs.devShells.${system}.hls; devShells.wasm = inputs.miso.outputs.devShells.${system}.wasm; devShells.ghcjs = inputs.miso.outputs.devShells.${system}.ghcjs; + devShells.mhs = inputs.miso-mhs.outputs.devShells.${system}.mhs; }); } From 33b8650aea886d9b208d7db44f9fffae6eb6f9cb Mon Sep 17 00:00:00 2001 From: "code@dmj.io" Date: Thu, 1 Oct 2026 08:00:45 -0500 Subject: [PATCH 2/4] Constrain aeson to >= 2 for the JS build The solver had started to pick aeson-0.8.0.2 (for ghcjs-base), which does not compile with GHC 9.12. --- cabal.project | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cabal.project b/cabal.project index 8cfd906..01a7026 100644 --- a/cabal.project +++ b/cabal.project @@ -4,6 +4,9 @@ packages: allow-newer: all:base +constraints: + aeson >= 2 + source-repository-package type: git location: https://github.com/dmjio/miso From d135d67bfd4185aba1a66d616809aea86b84f569 Mon Sep 17 00:00:00 2001 From: "code@dmj.io" Date: Thu, 1 Oct 2026 08:22:23 -0500 Subject: [PATCH 3/4] Use the mhs shell from miso master MicroHs support has been merged, so the separate miso-mhs input is gone and the miso input is updated to master. The ghcjs shell is now GHC 9.14.1, so build-js no longer hardcodes the GHC version in the path to all.js. --- Makefile | 2 +- flake.lock | 149 ++--------------------------------------------------- flake.nix | 4 +- 3 files changed, 6 insertions(+), 149 deletions(-) diff --git a/Makefile b/Makefile index 7634b35..641be2d 100644 --- a/Makefile +++ b/Makefile @@ -42,7 +42,7 @@ update-js: build-js: cabal build --with-ghc=javascript-unknown-ghcjs-ghc --with-hc-pkg=javascript-unknown-ghcjs-ghc-pkg - cp -v ./dist-newstyle/build/javascript-ghcjs/ghc-9.12.2/*/x/app/build/app/app.jsexe/all.js . + cp -v ./dist-newstyle/build/javascript-ghcjs/ghc-*/*/x/app/build/app/app.jsexe/all.js . rm -rf public cp -rv static public bunx --bun swc ./all.js -o public/index.js diff --git a/flake.lock b/flake.lock index 2b10929..08e9368 100644 --- a/flake.lock +++ b/flake.lock @@ -36,68 +36,11 @@ "type": "github" } }, - "flake-utils_3": { - "inputs": { - "systems": "systems_3" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, - "flake-utils_4": { - "inputs": { - "systems": "systems_4" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "ghc-wasm-meta": { "inputs": { "flake-utils": "flake-utils_2", "nixpkgs": "nixpkgs" }, - "locked": { - "host": "gitlab.haskell.org", - "lastModified": 1775305067, - "narHash": "sha256-KFWRYVYPgsXu51stX/7/416qc31HFltfQiHPc6nEmH0=", - "owner": "haskell-wasm", - "repo": "ghc-wasm-meta", - "rev": "60098a5076557e327b326a1a3ba3b5fb4fec1e49", - "type": "gitlab" - }, - "original": { - "host": "gitlab.haskell.org", - "owner": "haskell-wasm", - "repo": "ghc-wasm-meta", - "type": "gitlab" - } - }, - "ghc-wasm-meta_2": { - "inputs": { - "flake-utils": "flake-utils_4", - "nixpkgs": "nixpkgs_3" - }, "locked": { "host": "gitlab.haskell.org", "lastModified": 1789039765, @@ -121,73 +64,20 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1778664899, - "narHash": "sha256-N0wIPYEoqCKZqyAqNxQ87sjpijZZNAx+/sx2/Feot08=", - "owner": "dmjio", - "repo": "miso", - "rev": "efae40b82c1452891f78e79c139d6421983878a6", - "type": "github" - }, - "original": { - "owner": "dmjio", - "repo": "miso", - "type": "github" - } - }, - "miso-mhs": { - "inputs": { - "flake-utils": "flake-utils_3", - "ghc-wasm-meta": "ghc-wasm-meta_2", - "nixpkgs": "nixpkgs_4" - }, - "locked": { - "lastModified": 1790810291, + "lastModified": 1790860863, "narHash": "sha256-hH4cTxZwWcaNK3qaZO3tRMhwcDggmSiLwDKmqEx9ld0=", "owner": "dmjio", "repo": "miso", - "rev": "91fa9e576a925e22a35838f2a86b1fedf6698b1d", + "rev": "6edf9102a583aa4200cefe012b507082517aa49b", "type": "github" }, "original": { "owner": "dmjio", - "ref": "microhs", "repo": "miso", "type": "github" } }, "nixpkgs": { - "locked": { - "lastModified": 1774399958, - "narHash": "sha256-Q+g1Np4wyNYpylt8RFM8UprAmyRoA3q3EZj7lQV+ZuQ=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "735a15e91bcb1b3e0883a91d3c9dfd4475d1bc54", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixpkgs-25.11-darwin", - "repo": "nixpkgs", - "type": "github" - } - }, - "nixpkgs_2": { - "locked": { - "lastModified": 1751996040, - "narHash": "sha256-DOjNE+DYZ/YZo1UkXcJNlvSKEBowWATX6o4s0WuAzuA=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9e2e8a7878573d312db421d69e071690ec34e98c", - "type": "github" - }, - "original": { - "owner": "nixos", - "repo": "nixpkgs", - "rev": "9e2e8a7878573d312db421d69e071690ec34e98c", - "type": "github" - } - }, - "nixpkgs_3": { "locked": { "lastModified": 1789009968, "narHash": "sha256-GB16oaxpsrnGNnGIE+0uYBqMRzB9X6FYDUvjvnJAYew=", @@ -203,7 +93,7 @@ "type": "github" } }, - "nixpkgs_4": { + "nixpkgs_2": { "locked": { "lastModified": 1788881743, "narHash": "sha256-2V9GZGvPfrNzxFozhI9dcqV+c3QdA8YZrvAAzqEB+dI=", @@ -221,8 +111,7 @@ }, "root": { "inputs": { - "miso": "miso", - "miso-mhs": "miso-mhs" + "miso": "miso" } }, "systems": { @@ -254,36 +143,6 @@ "repo": "default", "type": "github" } - }, - "systems_3": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } - }, - "systems_4": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0850c61..0fcb5ff 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,6 @@ inputs = { miso.url = "github:dmjio/miso"; - # MicroHs (mhs) support lives on miso's microhs branch for now - miso-mhs.url = "github:dmjio/miso/microhs"; }; outputs = inputs: @@ -12,7 +10,7 @@ devShells.hls = inputs.miso.outputs.devShells.${system}.hls; devShells.wasm = inputs.miso.outputs.devShells.${system}.wasm; devShells.ghcjs = inputs.miso.outputs.devShells.${system}.ghcjs; - devShells.mhs = inputs.miso-mhs.outputs.devShells.${system}.mhs; + devShells.mhs = inputs.miso.outputs.devShells.${system}.mhs; }); } From 6ab36f6521a747254cb6a7eb299d53d06aef6fd8 Mon Sep 17 00:00:00 2001 From: "code@dmj.io" Date: Thu, 1 Oct 2026 12:43:09 -0500 Subject: [PATCH 4/4] Update miso to 4ebc461f For the ghcjs shell fix (dmjio/miso#1666) and the MicroHs rev bump (dmjio/miso#1665). --- flake.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/flake.lock b/flake.lock index 08e9368..ccf48c6 100644 --- a/flake.lock +++ b/flake.lock @@ -64,11 +64,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1790860863, - "narHash": "sha256-hH4cTxZwWcaNK3qaZO3tRMhwcDggmSiLwDKmqEx9ld0=", + "lastModified": 1790876521, + "narHash": "sha256-PSREqoUN7Tnpi50Kgnv9xN8Yk5Pd2aNkMnz65u7LzZE=", "owner": "dmjio", "repo": "miso", - "rev": "6edf9102a583aa4200cefe012b507082517aa49b", + "rev": "4ebc461f6379932cc95fc56b85a4cf5ff2288fde", "type": "github" }, "original": {