hasura / pg-client-hs

A low level Haskell library to connect to postgres
Apache License 2.0
25 stars 15 forks source link

[do not merge] haskell.nix build setup #49

Closed jkachmar closed 2 years ago

jkachmar commented 3 years ago

tl;dr I wanted to poke around with something while I was bored; I don't recommend that we merge this at all, but I decided to push it up in case anyone else was interested in taking a look.


This is more of an experiment than anything else; I don't think it's something that we'll necessarily ever want to merge, but I wanted to see how difficult it would be to get something up and running with IOHK's haskell.nix build framework.


There are a bunch of caveats here, but the quickstart is basically:

  1. Install Nix
  2. Set up the IOHK binary cache
  3. Clone this repo and checkout jkachmar/haskell-nix
  4. Enter the development shell with either nix develop or nix-shell (depending on whether your Nix installation supports Flakes or not)

That'll probably take a little while to build, but when it's finished it should drop you into a sandbox with GHC 8.10.5, cabal-install-3.4.0.0, haskell-language-server-1.3.0.0, and a GHC package DB loaded up with all of the project's dependencies (this allows someone to drop into a REPL with ghci and have access to all of the libraries instantly).


The value proposition here is threefold:

  1. The project can now be built with nix build .#pg-client:lib:pg-client in a way that's fully hermetic, down to the C libraries
  2. CI builds can be much more aggressively cached, and these caches can be shared with developers
    • i.e. CI can upload cached artifacts for all of the dependencies, so in an ideal scenario no one should have to rebuild anything on a fresh checkout
  3. The cached development environment from (2) can include all of the project's development dependencies, including a working Hoogle server