Skip to content

Commit 93f9e8f

Browse files
committed
Add Miso
1 parent 30f5fd2 commit 93f9e8f

File tree

14 files changed

+284
-25
lines changed

14 files changed

+284
-25
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ gen
1818
del
1919
static/prod.*
2020
Config/client_session_key.aes
21+
static/miso
2122

2223
# Ignore locally checked out IHP version
2324
IHP

.hie-bios

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
make print-ghc-options GHC_RTS_FLAGS='' | tr ' ' '\n' > "$HIE_BIOS_OUTPUT"
3+
echo "$HIE_BIOS_ARG" >> "$HIE_BIOS_OUTPUT"
4+
find . \
5+
-path './miso' -prune -o \
6+
-path './dist*' -prune -o \
7+
-path './Setup.hs' -prune -o \
8+
-name '*.hs' \
9+
-print \
10+
>> "$HIE_BIOS_OUTPUT"

Layout.hs.patch

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- Web/View/Layout.hs 2022-01-15 10:05:24.712496967 +0100
2+
+++ Layout.hs 2022-01-15 10:06:30.321569568 +0100
3+
@@ -54,6 +54,7 @@
4+
<script src={assetPath "/helpers.js"}></script>
5+
<script src={assetPath "/ihp-auto-refresh.js"}></script>
6+
<script src={assetPath "/app.js"}></script>
7+
+ <script src={assetPath "/miso/index.js"} type="module"></script>
8+
|]
9+
10+
devScripts :: Html

Makefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ JS_FILES += ${IHP}/static/vendor/morphdom-umd.min.js
1212
JS_FILES += ${IHP}/static/vendor/turbolinks.js
1313
JS_FILES += ${IHP}/static/vendor/turbolinksInstantClick.js
1414
JS_FILES += ${IHP}/static/vendor/turbolinksMorphdom.js
15+
JS_FILES += static/miso/index.js
16+
JS_FILES += static/miso/ghc_wasm_jsffi.js
1517

1618
include ${IHP}/Makefile.dist
1719

20+
static/miso/index.js:
21+
cp miso/index.js static/miso/
22+
23+
.ONESHELL:
24+
static/miso/ghc_wasm_jsffi.js:
25+
wasm32-wasi-cabal build Frontend
26+
hs_wasm_path=$(shell wasm32-wasi-cabal list-bin Frontend)
27+
hs_wasm_libdir=$(shell wasm32-wasi-ghc --print-libdir)
28+
"$$hs_wasm_libdir"/post-link.mjs --input "$$hs_wasm_path" --output static/miso/ghc_wasm_jsffi.js
29+
cp "$$hs_wasm_path" static/miso/bin.wasm

Welcome.hs.patch

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
--- Web/View/Static/Welcome.hs 2021-01-21 11:34:59.524263194 +0100
2+
+++ Welcome.hs 2021-01-21 11:35:42.646954932 +0100
3+
@@ -14,6 +14,9 @@
4+
<h2 style="margin-top: 0; margin-bottom: 0rem; font-weight: 900; font-size: 3rem">
5+
It's working!
6+
</h2>
7+
+ <div id="miso"></div>
8+
9+
<p style="margin-top: 1rem; font-size: 1.75rem; font-weight: 600; color:hsla(196, 13%, 80%, 1)">
10+
Your new application is up and running.

cabal.project

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
optional-packages: miso
2+
3+
if arch(wasm32)
4+
-- The global config for Wasm Cabal adds `:override` for `head.hackage`, which is often not what we want:
5+
-- https://gitlab.haskell.org/haskell-wasm/ghc-wasm-meta/-/issues/9#note_609714
6+
active-repositories: :rest, head.hackage.ghc.haskell.org
7+
8+
-- https://github.com/haskellari/splitmix/pull/73
9+
source-repository-package
10+
type: git
11+
location: https://github.com/amesgen/splitmix
12+
tag: cea9e31bdd849eb0c17611bb99e33d590e126164

flake.lock

Lines changed: 93 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
flake-parts.follows = "ihp/flake-parts";
66
devenv.follows = "ihp/devenv";
77
systems.follows = "ihp/systems";
8+
ghc-wasm-meta.url = "gitlab:haskell-wasm/ghc-wasm-meta?host=gitlab.haskell.org";
89
};
910

1011
outputs = inputs@{ self, nixpkgs, ihp, flake-parts, systems, ... }:
@@ -13,13 +14,14 @@
1314
systems = import systems;
1415
imports = [ ihp.flakeModules.default ];
1516

16-
perSystem = { pkgs, ... }: {
17+
perSystem = { pkgs, system, ... }: {
1718
ihp = {
1819
# appName = "app"; # Available with v1.4 or latest master
1920
enable = true;
2021
projectPath = ./.;
2122
packages = with pkgs; [
2223
# Native dependencies, e.g. imagemagick
24+
inputs.ghc-wasm-meta.packages.${system}.all_9_10
2325
];
2426
haskellPackages = p: with p; [
2527
# Haskell dependencies go here
@@ -43,6 +45,7 @@
4345
processes = {
4446
# Uncomment if you use tailwindcss.
4547
# tailwind.exec = "tailwindcss -c tailwind/tailwind.config.js -i ./tailwind/app.css -o static/app.css --watch=always";
48+
frontend.exec = "./watch-frontend";
4649
};
4750
};
4851
};

hie.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
# Used by haskell-language-server to find GHC settings
22
cradle:
3-
bios:
4-
shell: "$IHP/.hie-bios"
3+
multi:
4+
- path: "./miso"
5+
config:
6+
cradle:
7+
cabal:
8+
component: "exe:Frontend"
9+
- path: "."
10+
config:
11+
cradle:
12+
bios:
13+
shell: "./.hie-bios"

0 commit comments

Comments
 (0)