Conflicts when installing X11 headers

I’m trying to compile raylib from source, which has a dependency on X11. So I tried installing the xorg.libX11 package. However, the X11/Xlib.h header included in this package has a dependency on X11/X.h, which is for some reason not provided in this package, but in xorg.xorgproto. However, trying to install both of these packages results in the following error.

error: builder for '/nix/store/n79h71qxzfwac7s2qa364cvyliwd9h1d-home-manager-path.drv' failed with exit code 25;
       last 1 log lines:
       > error: collision between `/nix/store/8k70s0f3rjl2vg2776zilqfjrf0n8zjl-libX11-1.8.6-dev/include/X11/extensions/XKBgeom.h' and `/nix/store/94mjsik4j0mc9i9adigimqpyc4jf41pk-xorgproto-2023.2/include/X11/extensions/XKBgeom.h'
       For full logs, run 'nix log /nix/store/n79h71qxzfwac7s2qa364cvyliwd9h1d-home-manager-path.drv'.
error: 1 dependencies of derivation '/nix/store/79ylivni7g6gqny7f8sh52f90z9swbdl-home-manager-generation.drv' failed to build
# in my HomeManager config
packages = [
  ...
  # raylib's dependencies  
  mesa
  alsa-lib
  xorg.libX11.dev # adding the dev doesn't make a difference as far as I can tell
  xorg.libXft
  xorg.libXinerama
  xorg.xorgproto
  ...
] 

Running the nix log command only shows the one line

error: collision between `/nix/store/8k70s0f3rjl2vg2776zilqfjrf0n8zjl-libX11-1.8.6-dev/include/X11/extensions/XKBgeom.h' and `/nix/store/94mjsik4j0mc9i9adigimqpyc4jf41pk-xorgproto-2023.2/include/X11/extensions/XKBgeom.h'

Has anyone experienced something similar or have a workaround?

xorgproto is a dev library, I believe. I.e., it contains headers for building against Xorg, and shouldn’t be installed for running. Hence it probably conflicts.

Even if it did work, the packages added to home.packages won’t be properly configured for for development anyway.

You’ll likely want to create a devshell instead, and open it with nix-shell (or nix develop if you’re using flakes):

pkgs.mkShell {
  packages = with pkgs; [
    # raylib's dependencies  
    mesa
    alsa-lib
    xorg.libXft
    xorg.libXinerama
    xorg.xorgproto
    ...
  ];
}