This is the frontend for the MBIE Regional Activity web tool.
It works by reading the JSON data and YAML config files at compile time to produce a small javscript executable that can be shipped with the JSON data files.
Open two shells. One is going to run the ghc shell, the other will run a ghcjs shell.
In the first shell, the ghc one:
$ nix-shell -A shells.ghc
$ cabal update
$ cabal new-repl
.... # Lots of stuff...
*Bailiwick> :reload
That will compile the project, and start a web server running that you can connect to.
And in the other shell:
$ nix-shell -A shells.ghcjs
$ cabal new-build --ghcjs
That will compile the javascript code ready to be served by the first process.
Now you open your browser at http://localhost:3701
Note, you also need to add a 127.0.0.1 jsaddle.localhost
to your /etc/hosts
file
Passing nixpkgs
via command line here to avoid missing attribute
error for nodejs-8_x. TODO somehow pin the dev environment's nixpkgs,
and make sure it matches the docker base image's nixpkgs?
$ nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz javascript.nix -A shell
[nix-shell:bailiwick-ui]$ ln -sf $NODE_PATH
[nix-shell:bailiwick-ui]$ npm run develop
$ nix-env -f db/default.nix -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz -iA bailiwick-data
$ nix-shell db/default.nix -I nixpkgs=https://github.com/NixOS/nixpkgs-channels/archive/nixos-19.03.tar.gz --run 'make -BC db'
There is nix.conf
file that may need to be updated. It has a line to point at
the local store. To setup the local store:
$ nix-store --generate-binary-cache-key nix-cache.kahu.dragonfly.co.nz-1 nix-serve.sec nix-serve.pub
$ NIX_SECRET_KEY_FILE=nix-serve.sec nix-serve --host nix-cache.kahu.dragonfly.co.nz --port 8080
And in the nix.conf
file you will need to update the lines that refer to the
cache before running make docker
.
Currently the javascript is bundled via webpack (this will be moved to nix at some point).
To run, first install all the npm dependencies.
npm i
Then to watch for changes & compie:
npm run develop
To build for production:
npm run build