nixpkgs already has infrastructure to compile to wasi the same way you compile to other platforms like arm, darwin (macOS), musl, etc.
nix-build -A pkgsCross.wasi32.$pkg
i haven’t found any $pkg
there that actually builds though. coreutils
depends on posix stuff, busybox
tries to include a non-existent netdb.h
file. even hello
barfs inside i think some autotools-generated wrapper around fcntl
.
i don’t understand enough about wasm to know if it really is reasonable to think of it as a “system” the same was x86_64-linux
or aarch64-multiplatform
is a “system”, but if so i’d love the equivalent of this blog post showing how to use (or fix) the wasi32 system!
as a NixOS-on-Pinephone user i 100% support funding upstreaming efforts 😉 that’s the type of thing which can have really broad reach. you’d never know it unless you were specifically looking for it, but we’ve also got people maintaining those OpenEmbedded musl+systemd patches for our distro (along with way too many other non-musl systemd patches: like you point out, it’s just not the type of thing that gets cleaned up without some focused effort like this).