Help installing C dependency (FAISS) for Haskell bindings

Hi everyone,

I’m currently working on Haskell bindings for FAISS, and I need to include the C library (faiss_c) as a dependency during installation of the Haskell package (faiss-hs).

Right now, installing the FAISS C library manually looks like this:

git clone https://github.com/facebookresearch/faiss
cmake -B build . -FAISS_ENABLE_C_API=ON -BUILD_SHARED_LIBS=ON
make -C build -j faiss
export LD_LIBRARY_PATH=${faissCustom}/lib:$LD_LIBRARY_PATH

I’d like to automate this as part of the Haskell package installation process, ideally in a clean, cross-platform, Cabal/Nix/Stack-friendly way.

Questions:

  1. What’s the best practice for including and building C dependencies like this within a Haskell package?
  2. Are there examples of Haskell libraries or repositories that install C dependencies during setup, or at least manage them cleanly?
  3. Should I expect users to install faiss_c manually, or is it reasonable to build it from source as part of the Haskell package setup?

Any advice, pointers, or examples would be much appreciated. Thanks!

Yes. The most battle-tested example is probably zlib.