How to push my Haskell Stack build to Cachix

As it looks like you’ve figured out, doing stack build --nix builds your Haskell dependencies with stack and not Nix. You’re not able to push your Haskell dependencies to Cachix if you’ve built them with Stack.

I summed up some of the ways to build a Haskell project with Nix in this post:

The things that would be compatible with pushing to cachix are shellFor from Nixpkgs, and using haskell.nix.

If you wanted to be able to use both stack build --nix and nix-build (while using stack.yaml as a single-source-of-truth), then currently haskell.nix is your only option. Although shellFor from Nixpkgs is somewhat simpler, and may be easier if you are just starting out with Nix.

2 Likes