CLion "Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)" when building an application

When I use the nix-shell (with cmake, etc.) for building, I’ve no issues using “cmake && make” in the terminal.

When I use Clion in the nix-shell, I get a cmake error:

CMake Error at /nix/store/9d67jcm1wj09wqgffh8v5mkgil9psnrw-cmake-3.25.3/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find X11 (missing: X11_X11_INCLUDE_PATH X11_X11_LIB)
Call Stack (most recent call first):
  /nix/store/9d67jcm1wj09wqgffh8v5mkgil9psnrw-cmake-3.25.3/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /nix/store/9d67jcm1wj09wqgffh8v5mkgil9psnrw-cmake-3.25.3/share/cmake-3.25/Modules/FindX11.cmake:481 (find_package_handle_standard_args)
  src/libraries/qhotkey/CMakeLists.txt:39 (find_package)

I’ve no issues using cmake in the nix-shell in the terminal.

Any ideas why the IDE doesn’t seem to find the paths?

I already have all kind of stuff in my shell.nix for that project:

{ pkgs ? import <nixpkgs> {} }:
  pkgs.mkShell {
    # nativeBuildInputs is usually what you want -- tools you need to run
    nativeBuildInputs = [

I played around with the build settings and cmake settings. It worked in the end. :sweat_smile:

I’m running into the same error. Could you please share what exactly made it work?

Hm, I can’t even remember what I changed in my build settings.
Currently, I run clion inside this nix-shell:

And this is my CMakeLists.txt: