build.nix (1732B)
1 { pkgs, toolchain }: 2 pkgs.runCommand "tricu-haskell-wasm-probe" { 3 nativeBuildInputs = [ toolchain pkgs.haskellPackages.ghc pkgs.nodejs pkgs.python3 ]; 4 } '' 5 mkdir -p $out/bin native wasm 6 export HOME=$TMPDIR XDG_CACHE_HOME=$TMPDIR/cache 7 ghc -O2 -rtsopts -i${../../src} -outputdir native ${./Probe.hs} -o $out/bin/probe-native 8 wasm32-wasi-ghc -O2 -rtsopts -i${../../src} -outputdir wasm ${./Probe.hs} -o $out/bin/probe.wasm 9 ln -s ${pkgs.nodejs}/bin/node $out/bin/node 10 ln -s ${../demo-site} $out/site 11 cp ${./node-wasi.mjs} $out/bin/node-wasi.mjs 12 cp ${./prepare-compiler.mjs} $out/bin/prepare-compiler.mjs 13 cp ${./ts-compiler.mjs} $out/bin/ts-compiler.mjs 14 mkdir -p compiler-native compiler-wasm $out/compiler-data 15 ghc -O2 -rtsopts -i${../../src} -outputdir compiler-native -main-is CompilerProbe ${./CompilerProbe.hs} -o $out/bin/compiler-native 16 wasm32-wasi-ghc -O2 -rtsopts -i${../../src} -outputdir compiler-wasm -main-is CompilerProbe ${./CompilerProbe.hs} -o $out/bin/compiler.wasm 17 node ${./prepare-compiler.mjs} ${../demo-site} $out/compiler-data 18 printf 'main = putStrLn "hello wasm"\n' > Hello.hs 19 wasm32-wasi-ghc Hello.hs -o $out/bin/hello.wasm 20 test "$(wasmtime $out/bin/hello.wasm)" = 'hello wasm' 21 $out/bin/probe-native check 22 wasmtime $out/bin/probe.wasm check 23 for kind in codec deep distribution; do 24 $out/bin/probe-native "$kind" 64 2 25 wasmtime $out/bin/probe.wasm "$kind" 64 2 26 done 27 { ghc --version; wasm32-wasi-ghc --version; cabal --version; 28 wasm32-wasi-clang --version; wasmtime --version; ${pkgs.nodejs}/bin/node --version; 29 wasm32-wasi-ghc-pkg list; 30 } > $out/versions.txt 31 ln -s ${toolchain}/bin/wasmtime $out/bin/wasmtime 32 python3 ${./check-compiler.py} $out 33 ''