Could not find system library 'x11' required by the 'x11' crate

Hello guys! I’m working on a new rust project, but I’m getting the following
error message:

--- stderr
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: `PKG_CONFIG_ALLOW_SYSTEM_CFLAGS="1" PKG_CONFIG_ALLOW_SYSTEM_LIBS="1" "pkg-config" "--libs" "--cflags" "x11" "x11 >= 1.4.99.1"` did not exit successfully: exit status: 1
error: could not find system library 'x11' required by the 'x11' crate

I’m using the following shell.nix:

let
  rust-overlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz";

  pkgs = import <nixpkgs> {
    overlays = [ (import rust-overlay) ];
  };

  toolchain = pkgs.rust-bin.fromRustupToolchainFile ./toolchain.toml;
in
pkgs.mkShell rec {
  packages = [ toolchain ];

  buildInputs = with pkgs; [
    rustup

    xorg.libX11
    xorg.libXcursor
    xorg.libXrandr
    xorg.libXi

    shaderc
    directx-shader-compiler
    libGL
    vulkan-headers
    vulkan-loader
    vulkan-tools
    vulkan-tools-lunarg
    vulkan-validation-layers
  ];

  shellHook = ''
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath buildInputs)}";
  '';
}

does anyone know what I’m doing wrong?

Wild guess: nativeBuildInputs = [ pkgs.pkg-config ]; maybe?

I presume pkg-config is how the Rust crate in question would locate the X11 libraries it wants to find.

EDIT: duh, didn’t horizontally scroll the error message - it says so in there :slight_smile:

1 Like

thank you! That was it :slight_smile: