Building Purescript Projects with Nix (using Psc-Package2Nix)

From Twitter: https://twitter.com/jusrin00/status/1106907846363488256

Qiita: https://qiita.com/kimagure/items/d2687a5a68c84cc651d0
GitHub: https://github.com/justinwoo/my-blog-posts/blob/master/posts/2019-03-16-building-purescript-projects-with-nix.md

Some people have asked me about this recently, so I looked some more into it and wrote it up.

1 Like

It’s interesting how the generated nix packages have a build step of ln -s. I’m used to seeing all nix packages having a more complicated one. Looks like this is the difference between language dependencies and binary dependencies, which is fun to take note of. Makes me wonder what would change in the nix psc-package definitions when one would want to use them for JavaScript projects, as it seems a bit like a waste to define an entirely different nix package definition to use one of those libraries in a slightly different way, which would be just a different build step for that package.

Anyways, just making conversation here. :grin: A useful reference!

Couple things to know about why ln -s is there:

  • I need to attach the “version” and “name” attributes to the packages. I do not want to use override on the actual sources, because this will cause me to have an incompatible Nix store entry from the actual source. The incompatibility comes from the same idea that for a given set { a = 123 }, this is not equal to { a = 123; b = 234; }.
  • A Nix derivation must always produce an output. Overall, Nix build outputs are a bunch of symlinks all the way down, which you can find by inspecting the contents of ~/.nix-profile and such and inspecting it.