Building zlib for Haskell with a development flake

Hi NixOS discourse,

Trying really hard to learn nix and have an easier time with setting up dev envs. Today I tried to build the Haskell package for zlib: GitHub - haskell/zlib: Compression and decompression in the gzip and zlib formats

here’s a flake I picked up and modified from haskell-language-server:

{
  inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; };

  outputs = { self, nixpkgs }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs { inherit system; };
      mkDevShell = hpkgs:
        with pkgs;
        mkShell {
          buildInputs = [
            hpkgs.ghc
            hpkgs.cabal-install

            zlib
            zstd
            xz
            bzip2
          ];

          shellHook = ''
            export LD_LIBRARY_PATH=${bzip2.out}/lib:${gmp}/lib:${zlib}/lib:${ncurses}/lib:${capstone}/lib:${zstd.out}/lib:${xz.out}/lib
          '';
        };
    in { devShells.${system}.default = mkDevShell pkgs.haskellPackages; };

}

and here’s a log from cabal build --enable-debug-info=3 -v -j1

Now at first I had to populate the buildInputs with the corresponding libraries and then LD_LIBRARY_PATH below, based on what the error during building was, but now I don’t see the issue at first glance beyond maybe that it has something to do with hsc2hs.

This doesn’t come up when using my system packages and ghcup, so I’m making a thread here, any help and tips will be appreciated :slight_smile: