Haskell toolchain on Nix
Troubleshooting
Failed with zlib-xxx during stack build
or cabal v2-build
This happened because stack/cabal failed to detect system libraries.
Solution: For stack,
yaml
# stack.yaml
# or globally ~/.stack/config.yaml
nix:
enable: true # This may have already been enabled on NixOS
packages: [zlib.dev, zlib.out]
For cabal, add pkgs.zlib
into devshell and set LD_LIBRARY_PATH
for cabal linker to find libraries.
nix
mkShell rec {
buildInputs = [
...
zlib
];
# Ensure that libz.so and other libraries are available to TH
# splices, cabal repl, etc.
LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs;
}
Ref: