How to install GTK 3 headers?


I have a working (on macOS, Debian and Ubuntu) CMakeList.txt which contains the following:

pkg_check_modules(GTK3 REQUIRED gtk+-3.0)

I get this:

stanislas@nixpsla ~/p/f/build> (master|✔) cmake ..
-- Checking for module 'gtk+-3.0'
--   No package 'gtk+-3.0' found
CMake Error at /nix/store/lkpvvfj7r1838c7aifcpvj9scpgi3j61-cmake-3.13.4/share/cmake-3.13/Modules/FindPkgConfig.cmake:452 (message):
  A required package was not found
Call Stack (most recent call first):
  /nix/store/lkpvvfj7r1838c7aifcpvj9scpgi3j61-cmake-3.13.4/share/cmake-3.13/Modules/FindPkgConfig.cmake:622 (_pkg_check_modules_internal)
  CMakeLists.txt:15 (pkg_check_modules)

I installed the gtk3 derivation. What am I missing?


You will also need to add pkgconfig and make sure you are following


Headers and libraries are not in a system-wide search path. You can enter an environment with the headers visible using nix-shell, e.g.:

nix-shell -p gtk3 pkgconfig

You can also make a default.nix, specifying the build dependencies:

with import <nixpkgs> {};
stdenv.mkDerivation {
  name = "env";
  buildInputs = [
    gtk3 pkgconfig

Then you can run nix-shell in the directory where default.nix resides.

1 Like