Thanks for the follow-up.
To summarize the email thread, it sounds like GCC is used directly by cabal configure
, and GCC is patched in nixpkgs to looks at environment variables like NIX_LDFLAGS. nix-shell (or is it stdenv.mkDerivation?) automatically populates NIX_LDFLAGS based on buildInputs. This chain of events causes cabal build
to work.
However, in the case of cabal repl
, GCC is not used, and GHC is directly responsible for loading and linking libraries. GHC doesn’t know anything about the NIX_LDFLAGS environment variables, so it is not able to find zlib.
The solution you’re proposing is to just modify LD_LIBRARY_PATH so that GHC can find zlib. Given the above info, it makes sense that this would work.
I guess there is also an argument to be made that we should wrap GHC in nixpkgs to make it aware of things like NIX_LDFLAGS. However, in the email thread linked above, peti makes the argument that he would rather have users using ghcWithPackages than raw cabal + GHC.