https://github.com/reflex-frp/reflex-platform/blob/develop/docs/project-development.md
We're piggy-backing off reflex-platforms nix infrastructure because it provides a working, cached, environment in which to develop with GHCJS. We'll be using GHC(JS) 8.4.
Most reflex-platform projects split the codebase into code needed to be compiled on GHC (backend project), code needed to be compiled by GHCJS (frontend project) and code shared between the two (common project). For simplicity, and because axiom can be compiled by either compiler, we just define one frontend project in our default.nix. More scalable projects would also follow the tripartate project structure.
So create a project as defined above in the project-development.md with only definitions for a "frontend" project. Then put the above default.nix in the base directory and nix-build to pull the requisit packages.
The haskell-ide-engine has some support for nix projects here.
Once you've run nix-build ., you can add support for GHC 8.4 to your environment by following the readme.
Once installed, you can enter the compiler shell of your choice with nix-shell -A shells.ghc8_4 or nix-shell -A shells.ghcjs8_4 and from there, launching an editor ((spac)emacs / vs code) inside the shell with support for hie should pick up the correct executables and packages and give you nice development experience.
See the default.nix and reflext-platforms's project function for how the various attributes in the nix expression are defined.
./build will run the needed cabal commands in their respective shells.
The cabal commands will put binaries under dist-newstyle and dist-ghcjs respectively. To run these, the rename the ghcjs binary to out.jsexe and put it in a static/ directory in the same location as the ghc binary:
.
├── frontend
└── static
└── out.jsexe
Then run the axiom app as usual, eg: ./frontend -p start/localhost/8080
Note: if you're running services in transient-universe that rely on the monitor or executor executables, you may need to execute ./frontend -p start/localhost/8080 from within nix-shell -A shells.ghc8_4 to allow nix to see those paths. Derivation coming soon.
Requires supporting the jsaddle api in axiom
Requires more work in axiom to support these architectures.