This is basically what the stack
builder in Nixpkgs does:
The big problem with this is that it is not pure. stack
uses the internet to fetch dependencies, so you need to disable the sandbox when you’re building. (I imagine it is possible you could work around this with a FOD for the Haskell deps that stack
downloads, but I’ve never seen someone attempt that.)
While some people use impure builds as a first step in moving to Nix, most people try to keep their Nix-based builds pure. In practice, you don’t see many people recommending these types of impure builds.
Most people would consider building like this a “problem”, but I guess it is up to you if you’re okay with it.
As for what I would suggest you do, I wrote up a post that explains your main choices for building Haskell projects with Nix:
If you want to build a Haskell project with Nix, using a stack.yaml
as a single source of truth, and not using haskell.nix, as far as I know you’re currently out of luck.
There is an old project that did this, but I don’t think anyone is maintaining it right now:
Although, this is something that people ask for frequently, so if you wanted to take the initiative to update this project and get it working with the latest version of stack
, you may very well have some appreciative users!