Nix performance on Travis and CircleCI

I am running into some major performance problems building a quite simple Haskell project using nix on Travis and CircleCI. Has anyone else run into this and have any advice about how to work around it?

To give some indication:

local: 25s
CircleCI: 6mins 35 
local: 56
CircleCI: Currently 24 minutes

https://circleci.com/gh/mpickering/eventlog2html/8

Most likely it takes a while to download everything. You can probably improve things a bit using CircleCI caching (of /nix/store):

You would get better debugging information with nix-build. The new nix build is quite terse, and works better for interactive use.

I have switched to nix-build now and it shows that some things were not being cached which I thought would be. I’ve tried pushing them locally to the cache now so we’ll see if that improves things.

After adding everything to the cache build times are sensible. I think the long time taken to perform CI was due to some build dependencies needing to be added to the cache. Moral of the story, initialise the cache
locally if your CI machine is slow.