numtide / devshell

Per project developer environments
https://numtide.github.io/devshell/
MIT License
1.22k stars 87 forks source link

`language.c.includes` collision when trying to use libX11 and xorgproto #241

Open duckpuppy opened 1 year ago

duckpuppy commented 1 year ago

Describe the bug

xorg.libX11 and xorg.xorgproto both contain some of the same files, but both are often needed when working with X11 libs. Including both of them in language.c.includes causes a collision.

To Reproduce

Steps to reproduce the behavior:

  1. Initialize a devshell flake.nix
  2. Create a devshell.toml file with:
    imports = [ "language/c" ]
    [language.c]
    compiler = "pkgs.gcc-unwrapped"
    includes = [ "xorg.libX11", "xorg.xorgproto" ]

Expected behavior

Include files from both packages are on the include path

System information

WSL2 / Debian Bullseye

Additional context

I'm trying to work on a golang project that uses SDL2 (and as such needs the C compiler as well), and SDL2 requires both libX11 and xorgproto.

flake.nix:

{
  description = "virtual environments";

  inputs.devshell.url = "github:numtide/devshell";
  inputs.flake-utils.url = "github:numtide/flake-utils";

  outputs = { self, flake-utils, devshell, nixpkgs }:
    flake-utils.lib.eachDefaultSystem (system: {
      devShell =
        let pkgs = import nixpkgs {
          inherit system;

          overlays = [ devshell.overlay ];
        };
        in
        pkgs.devshell.mkShell {
          imports = [ (pkgs.devshell.importTOML ./devshell.toml) ];
        };
    });
}

devshell.toml:

# https://numtide.github.io/devshell
imports = [
  "language/c"
]

[language.c]
compiler = "pkgs.gcc-unwrapped"
includes = [
  "SDL2", 
  "xorg.libX11",
  "xorg.xorgproto"
]

[[commands]]
package = "devshell.cli"
help = "Per project developer environments"

[[commands]]
package = "go"
help = "Golang language compiler"

[devshell]
packages = [
  "delve",
  "golangci-lint",
  "gopls",
  "gomodifytags",
  "pkg-config"
]

The above configuration gives the following error:

error: builder for '/nix/store/fv8qvjd82wmrm1s0qb6ca3w5d6q9z2ab-devshell-dir.drv' failed with exit code 25;
       last 1 log lines:
       > error: collision between `/nix/store/2dspcvr8zwwcl35pilbsgqhnid3kfh68-xorgproto-2021.5/include/X11/extensions/XKBgeom.h' and `/nix/store/sgw0sxwx46hqwlcm3d834f10p1qx7c5y-libX11-1.8.1-dev/include/X11/extensions/XKBgeom.h'
       For full logs, run 'nix log /nix/store/fv8qvjd82wmrm1s0qb6ca3w5d6q9z2ab-devshell-dir.drv'.
error: 1 dependencies of derivation '/nix/store/2cb7rrqfrx2ry2aw1qi4cx3kbpkbi2sa-devshell-env.drv' failed to build