573 / purescript-multi-nix

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

purescript-multi-nix

A demo of a multi-package PureScript project (monorepo) nixified using purs-nix.

Layout

Like haskell-multi-nix, this repository has two packages:

  • ./foo -- a PureScript library.
  • ./bar -- a PureScript executable, that depends on ./foo

Building packages

PureScript package

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.

JavaScript bundle

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?

Building the ./bar application

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

Dev shell

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.

About


Languages

Language:Nix 90.6%Language:PureScript 9.4%