Spago2Nix: generate Nix expressions from Spago

#1

At ZuriHac, I put together a utility to generate Nix expressions from Spago. It requires Spago 0.8.5.0, which is available now either via npm or from easy-purescript-nix

https://github.com/justinwoo/spago2nix

How do I use this?

From https://github.com/justinwoo/spago2nix#usage

First, generate the spago-packages.nix:

$ spago2nix generate
getting packages..
got 65 packages from Spago list-packages.
# ...
wrote spago-packages.nix

Then install these, optionally with more jobs provided to Nix:

$ spago2nix install -j 100
/nix/store/...-install-spago-style
installing dependencies...
# ...
done.
Wrote install script to .spago2nix/install

Then build the project:

# SOON: spago --no-install
$ spago2nix build
/nix/store/...-build-spago-style
building project...
done.
Wrote build script to .spago2nix/build

How does this work?

  1. I call Spago list-packages
  2. I generate Nix derivations for each package
  3. I give you ways to generate bash scripts that will ensure these inputs are available:

This means that once you have these, you really don’t need much more than to run nix-build spago-packages.nix -A installSpagoStyle to install these packages in your Nix store and get the bash script to copy these packages from your store to your project.

Of course, since I make this expression readily available to you, you can also choose to manipulate these in ways you see fit.

Why?

<insert generic Nix explanation>

I also needed this to replace my usage of Psc-Package2Nix with spago psc-package-insdhall on some of my projects.

Further questions

You should ask any specific questions in issues on the repo.

6 Likes
#2

Here’s a post about this project: https://github.com/justinwoo/my-blog-posts/blob/master/posts/2019-06-22-spago2nix-why-and-how.md

1 Like