Get reliable path to devShell package files?

I’m trying to compile a project that relies on the xorg.libX11 and libxcbcommon packages. I’ve added those packages to my devShell, and I can see their paths in NIX_CFLAGS_COMPILE environment variable.

However, the build system I’m using requires the actual paths, not a string to be passed to the compiler. Is there a way to either a) look up the nix store path of the package in a reliable way that doesn’t require hard-coding a store hash, or b) accessing the installed packages via a fixed symlink (kind of like you get with ~/.nix-profile)?

You could e.g. make your shell set an environment variable that contains the path and access that:

pkgs.mkShell {
  LIBXCBCOMMON_PATH = "${pkgs.libxcbcommon}";
}
1 Like

So simple yet brilliant. Thanks!