Add MicroHs support.
We'd like to add support for @augustss's MicroHs project as a first class citizen, to explore its cross-compilation capabilities (w/ emscripten, and other platforms).
This PR fetches MicroHs at master and builds using the recommended Makefile workflow. We make install into /nix/store during the installPhase, along with other tools. This PR introduces 3 derivations to facilitate the process of getting a miso MicroHS build into miso's CI.
-
The
microhsnix package placescpphs,mhsandmcabalinside of$out/bin. We also copylib,generated,src,boards,docs, into$out(aka/nix/store/). -
We now acquire
mcabal,mhsandcpphsthrough themakeC bootstrapping install, and have a derivation formhsbuilt w/ GHC (separately). -
We have created a
targets.conffile that lives in the/nix/storethatmhsnow uses to setCCandCC-FLAGScorrectly. -
microhs-envis a shell environment (cd miso/micro && nix-shell) that includes both of the above packages. Usingnix-shellwe can now enter an environment wheremhsis present on$PATHand points to the correct$MHSDIR, along with all the other build tools present (cpphs,mcabal).
To test, clone miso and call nix-shell --argstr pkg micro --run 'mhs --version'
- [x] Build MicroHS into miso's nixpkgs (
mcabal,mhs,cpphs) - [x] Create 3 derivations for microhs (
microhs,microhs-env,microhs-wrapper) - [x] Introduce
micro/subdirectory with a newmiso.cabalthat MicroHS supports - [x] Add MicroHs shell environment to
shell.nix(command above), edit: addsnodejsandemscriptentoo - [x] Ensure
MicroHsworks on Darwin OSX - [x] Ensure emscripten builds C files on Darwin (https://github.com/NixOS/nixpkgs/issues/139943#issuecomment-930432045)
- [x] Compile and run fibs
Example.hsin CI for x86 - [x] Ensure emscripten JS payloads run in QuickJS
- [x] Compile and run fibs
Example.hsin CI for JS (even w/-temscriptengccis still chosen (andtargets.confhas both). - [ ] Use
mcabal installto fetch and build all of miso's dependencies (WIP) - [x] Explore adding support for a JS FFI (
foreign import javascript&js-sources:) viaemscripten(this might require modifications tomhsandmcabal). https://github.com/augustss/MicroHs/issues/217 - [ ] Add
js-sourcestomcabal - [ ] Add
JSValto MicroHS (https://github.com/dmjio/miso/issues/1100) - [ ] Place miso's MicroHS build under CI using both
emscriptenandnative - [ ] Consider upstreaming MicroHs into nixpkgs proper (with
pkgsCrosssupport) -- using the traditional haskell nixpkgs workflow
For JSFFI support (for browser targets) w/ emscripten research the following
- https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html#calling-javascript-from-c-c
There is a stack overflow in the latest emscripten
https://github.com/dmjio/miso/actions/runs/15972581883/job/45046966990#step:26:679
https://github.com/NixOS/nixpkgs/pull/460845