Let’s say the headers of your local library are in /home/user/src/mylib/include and the library files (*.so or *.a) are in /home/user/src/mylib/lib. Then you can put the following into your stack.yaml (tested with stack v2.2.0; instructions for cabal-install should be similar):
extra-include-dirs:
"$locals": -optl=-Wl,-rpath,/home/user/src/mylib/lib Here "$locals" means “apply the options to all local packages”.