A demo of a multi-package PureScript project (monorepo) nixified using purs-nix.
Like haskell-multi-nix, this repository has two packages:
./foo
-- a PureScript library../bar
-- a PureScript executable, that depends on ./foo
A "PureScript package" is, alas, a mere copy of the .purs source files. To build the foo PureScript package:
nix build .#foo
Note that if you are on M1, you must add --option system x86_65-darwin
because of purs-nix/purs-nix#17.
Unlike PureScript packages, a JavaScript bundle is probably more useful inasmuch as compilation actually happens as part of the build. The PureScript package, above, will succeed in building even if there is a syntax error in the source tree.
To build the foo JS bundle:
nix build .#foo-js
This produces the compiled JavaScript at ./result.
TODO: How to evaluate this (the library function) the NodeJS repl?
Using the instructions above on how to build the ./foo package, we can likewise build the ./bar application:
nix build .#bar
The above is of course not very useful, so let us build the ./bar application JS bundle:
nix build .#bar-js
Now we can run the result directly in the NodeJS evaluator!
❯ node ./result
Nix, Nix
Nix, Nix
Nix, Nix
The dev shell is a work-in-progress. Since purs-nix itself does not support a multi-package purs-nix
command yet, we create a ghost top-level package and then produce the purs-nix
command for it. See devShells.default
in flake.nix.