For the shell, I add
shellHook = ''
export LD_LIBRARY_PATH=${pkgs.lib.makeLibraryPath [
pkgs.stdenv.cc.cc
]}
'';
to mkShell. (with stdenv.cc.cc and other libs that my python dependencies need)
I don’t know if it’s the best way to do it, though