Fil-C on Nix

Filnix wiki

mbrock/filnix

nanofil/web/play/trealla-wasm.nix

Trealla as a WASI command (tpl.wasm), at the revision and with the patches nanofil runs on natively (../../nix/trealla.nix), for the playground. trealla-js 0.30.1 traps on nanofil's pipeline ("function signature mismatch"), and lacks those patches.

nix build -f nanofil/web/play/trealla-wasm.nix
λpkgs?
pkgsdefault importbuiltins.getFlaketoString../../...inputs.nixpkgs system = "x86_64-linux";
let
13native=
import../../nix/trealla.nix inherit pkgs;
14wasi=
pkgs.pkgsCross.wasi32
in
pkgs.stdenvNoCC.mkDerivation
17pname=
"trealla-wasm"
18inherit native
version src patches
19nativeBuildInputs=
wasi.stdenv.cc pkgs.stdenv.cc pkgs.binaryen pkgs.xxd
25postPatch=
native.postPatch or ""
26buildPhase=
runHook preBuild
make -j$NIX_BUILD_CORES WASI=1 WASI_CC=${wasi.stdenv.cc.targetPrefix}cc \
HOST_CC=cc OPT='-O3 -DNDEBUG' GIT_VERSION='"${native.version}-filnix"' tpl.wasm
wasm-opt --enable-bulk-memory --enable-nontrapping-float-to-int \
--enable-sign-ext --enable-mutable-globals -O3 tpl.wasm -o tpl-opt.wasm
runHook postBuild
34installPhase=
mkdir -p $out
cp tpl.wasm $out/tpl-unopt.wasm
cp tpl-opt.wasm $out/tpl.wasm