As far as I can tell,
stack can not install GHC on its own due to how nix works.
It needs to rely on nix to provide a GHC version fitting to the snapshot version.
However, currently it might very well happen that some GHC that you require is not in the current stable channel. I am thinking about old GHC versions, such as
8.2.1. But also newer builds do not all exist, such as
8.4.2. Since there are still lts versions where the GHC version is old, and there are projects that try to support old versions of GHC, it is currently not possible to test nor even build these projects without rewriting a substantial amount of code.
In my opinion, this is a problem, operating systems should not dictate the usage of build systems.
I have talked about this in the IRC, and Pinning Nixpkgs was named as a solution to download old versions of GHC.
This requires duplicate work for every developer on NixOS who tries to contribute to projects that support old GHC versions, since everyone needs to pin nixpkgs on their own, or have to explicitly add support for nix in their Haskell project. In general, I do not feel like we can demand that for every project.
I am curious whether there is a way to solve this problem, e.g. provide a set of all GHCs, or at least for every Stack snapshot, such that every snapshot in stack can always be built on NixOS. I am focusing on
stack here, since the whole purpose of
stack is to provide a unified build experience for all major platforms, which nix is currently breaking.