Hello
I’m trying to make a shell.nix for my Haskell library (on macOS) which loads a DLL at runtime, but am confused about how paths happen. Here’s my shell.nix:
{ pkgs ? import <nixpkgs> {} }:
let
qtlzma = pkgs.callPackage ./qtlzma.nix {};
buildInputs = with pkgs; [ cabal-install pkgconfig qtlzma ];
in
pkgs.mkShell {
inherit buildInputs;
}
The DLL is in the qtlzma package. On my system it lives at /nix/store/jhfi6nq7rnqn83ivs52dvclmh890awzw-QtLZMA-master/lib/libqtlzma.dylib.
My cabal file has extra-libraries: qtlzma
, and within nix-shell, cabal new-build
successfully builds the library. How did cabal know where to find libqtlzma.dylib?
Within the same nix-shell cabal new-repl
fails because it can’t find libqtlzma.dylib. Interestingly, it lists ~/.nix-profile/lib as a search directory (how did it know to look there?). But if I try:
pkgs.mkShell {
inherit buildInputs;
DYLD_LIBRARY_PATH = "${qtlzma}/lib";
}
DYLD_LIBRARY_PATH remains unset inside the nix-shell! Why?
Moreover, in Nix, what is the best way to develop projects depending on shared libraries?
Thanks in advance!