How to find gtkmm/overlay.h

I want to build the package syslock, but even though I added gtkmm4 in buildinput or nativebuildinput, it still says that the header file cannot be found.

syslock> src/window.hpp:2:10: fatal error: gtkmm/overlay.h: No such file or directory                                                                                                   
syslock>     2 | #include <gtkmm/overlay.h>                                                                                                                                             
syslock>       |          ^~~~~~~~~~~~~~~~~                                                                                                                                             
syslock> compilation terminated.                                                                                                                                                        
syslock> make: *** [Makefile:78: src/main.o] Error 1                                                                                                                                    
error: builder for '/nix/store/bb6si2f0zfr3jjamxvy62sz0als1w6q8-syslock-0.1.drv' failed with exit code 2;                                                                               
       last 10 log lines:                                                                                                                                                               
       > to the PKG_CONFIG_PATH environment variable                                                                                                                                    
       > No package 'pam' found                                                                                                                                                         
       > [2/14] Compiling src/main.o                                                                                                                                                    
       > In file included from src/main.hpp:2,                                                                                                                                          
       >                  from src/main.cpp:1:
       > src/window.hpp:2:10: fatal error: gtkmm/overlay.h: No such file or directory
       >     2 | #include <gtkmm/overlay.h>
       >       |          ^~~~~~~~~~~~~~~~~
       > compilation terminated.
       > make: *** [Makefile:78: src/main.o] Error 1
       For full logs, run 'nix log /nix/store/bb6si2f0zfr3jjamxvy62sz0als1w6q8-syslock-0.1.drv'.
error: 1 dependencies of derivation '/nix/store/q3mp60aszg3i94l6j55hccv0kyfj2524-home-manager-path.drv' failed to build
error: 1 dependencies of derivation '/nix/store/j6nkinlc9sk9q1alg7h6zjq812f59zwr-home-manager-generation.drv' failed to build
┏━ 1 Errors: 
┃ error: builder for '/nix/store/bb6si2f0zfr3jjamxvy62sz0als1w6q8-syslock-0.1.drv' failed with exit code 2;
┃        last 10 log lines:
┃        > to the PKG_CONFIG_PATH environment variable
┃        > No package 'pam' found
┃        > [2/14] Compiling src/main.o
┃        > In file included from src/main.hpp:2,
┃        >                  from src/main.cpp:1:
┃        > src/window.hpp:2:10: fatal error: gtkmm/overlay.h: No such file or directory
┃        >     2 | #include <gtkmm/overlay.h>
┃        >       |          ^~~~~~~~~~~~~~~~~
┃        > compilation terminated.
┃        > make: *** [Makefile:78: src/main.o] Error 1
┃        For full logs, run 'nix log /nix/store/bb6si2f0zfr3jjamxvy62sz0als1w6q8-syslock-0.1.drv'

nix-index tells me the file is in gtkmm4.dev:

$ nix-locate gtkmm/overlay.h
gtkmm3.dev                                        8,970 r /nix/store/6wq89wyq530zwixmb1vb64kihv5qmanr-gtkmm-3.24.9-dev/include/gtkmm-3.0/gtkmm/overlay.h
gtkmm4.dev                                        8,278 r /nix/store/qb1w78dn3anp22v3v5gx66ish9kzihmx-gtkmm-4.12.0-dev/include/gtkmm-4.0/gtkmm/overlay.h

Try using that instead of just gtkmm4?

dev is the output chosen by mkDerivation when it exists nixpkgs/pkgs/stdenv/generic/make-derivation.nix at cedd087b81c6cb587b3bb75cca3bd793f813f71e · NixOS/nixpkgs · GitHub so no need to specify it

The issue here is that the Cflags of the gtkmm-4.0.pc aren’t added to the compiler invocation

This may be because of the error that can be seen in your log

to the PKG_CONFIG_PATH environment variable                                                                                                                                    
       > No package 'pam' found                             

which may then prevent pkg-config from outputting the other flags (Just a guess I don’t recall if pkg-config does that if it doesn’t find one)

add pam to nativebuild input is work. but has another err.

my derivation

{
  fetchFromGitHub,
  pkg-config,
  stdenv,
  lib,
  libevdev,
  gtkmm4,
  glibmm,
  gtk4-layer-shell,
  git,
  gtk-session-lock,
  pam
}:
stdenv.mkDerivation (finalAttrs: {
  pname = "syslock";
  version = "0.1";
  src = fetchFromGitHub {
    owner = "System64fumo";
    repo = finalAttrs.pname;
    rev = "8856cddbf205886a4c3b09f1669c0e6b8e435dbb";
    sha256 = "sha256-YC1G00bSTMyjC0vhZ3yxMzs3Jnb2oDnfHwtfDkRofbY=";
  };

  nativeBuildInputs = [ 
    pkg-config
    git
    libevdev
    gtkmm4.dev
    pam
    gtk4-layer-shell
    gtk-session-lock
  ];

  buildInputs = [
    glibmm
    gtkmm4
  ];

})
this derivation will be built:
  /nix/store/yxgknrwcx6n22jzlldlsgwihpfmq2bpc-syslock-0.1.drv
these 2 paths will be fetched (0.05 MiB download, 0.33 MiB unpacked):
  /nix/store/zjc38x3lskl1dhjbi3y31qxyfcbw21j8-gtk-session-lock-0.2.0
  /nix/store/2xpchjmlj66g7085rj63in8yhx9b7153-gtk-session-lock-0.2.0-dev
copying path '/nix/store/zjc38x3lskl1dhjbi3y31qxyfcbw21j8-gtk-session-lock-0.2.0' from 'https://mirror.sjtu.edu.cn/nix-channels/store'...
copying path '/nix/store/2xpchjmlj66g7085rj63in8yhx9b7153-gtk-session-lock-0.2.0-dev' from 'https://mirror.sjtu.edu.cn/nix-channels/store'...
building '/nix/store/yxgknrwcx6n22jzlldlsgwihpfmq2bpc-syslock-0.1.drv'...
Running phase: unpackPhase
unpacking source archive /nix/store/39cljd7gq36shhbg8cjpwiwzvgnldg9j-source
source root is source
Running phase: patchPhase
Running phase: updateAutotoolsGnuConfigScriptsPhase
Running phase: configurePhase
no configure script, doing nothing
Running phase: buildPhase
build flags: SHELL=/nix/store/516kai7nl5dxr792c0nzq0jp8m4zvxpi-bash-5.2p32/bin/bash
[1/14] Creating src/git_info.hpp
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
[2/14] Compiling src/main.o
[3/14] Compiling src/config_parser.o
[4/14] Linking syslock
make: *** No rule to make target '/usr/share/wayland-protocols/staging/ext-session-lock/ext-session-lock-v1.xml', needed by 'src/ext-session-lock-v1.h'.  Stop.
error: builder for '/nix/store/yxgknrwcx6n22jzlldlsgwihpfmq2bpc-syslock-0.1.drv' failed with exit code 2;
       last 10 log lines:
       > Running phase: buildPhase
       > build flags: SHELL=/nix/store/516kai7nl5dxr792c0nzq0jp8m4zvxpi-bash-5.2p32/bin/bash
       > [1/14] Creating src/git_info.hpp
       > fatal: not a git repository (or any of the parent directories): .git
       > fatal: not a git repository (or any of the parent directories): .git
       > fatal: not a git repository (or any of the parent directories): .git
       > [2/14] Compiling src/main.o
       > [3/14] Compiling src/config_parser.o
       > [4/14] Linking syslock
       > make: *** No rule to make target '/usr/share/wayland-protocols/staging/ext-session-lock/ext-session-lock-v1.xml', needed by 'src/ext-session-lock-v1.h'.  Stop.
       For full logs, run 'nix log /nix/store/yxgknrwcx6n22jzlldlsgwihpfmq2bpc-syslock-0.1.drv'.
{
  fetchFromGitHub,
  fetchurl,
  pkg-config,
  stdenv,
  lib,
  libevdev,
  gtkmm4,
  glibmm,
  gtk4-layer-shell,
  git,
  gtk-session-lock,
  pam,
  kdePackages,
  wrapGAppsHook4,
}:
let
  wayland-protocols = rec {
    pname = "wayland-protocols";
    version = "1.38";
    src = fetchurl {
      url = "https://gitlab.freedesktop.org/wayland/${pname}/-/releases/${version}/downloads/${pname}-${version}.tar.xz";
      hash = "sha256-/xcpLAUVnSsgzmys/kLX4xooGY+hQpp2mwOvfDhYHb4=";
    };
  };
in

stdenv.mkDerivation (finalAttrs: {
  pname = "syslock";
  version = "0-unstable-2024-11-17";
  src = fetchFromGitHub {
    owner = "System64fumo";
    repo = finalAttrs.pname;
    rev = "8856cddbf205886a4c3b09f1669c0e6b8e435dbb";
    sha256 = "sha256-YC1G00bSTMyjC0vhZ3yxMzs3Jnb2oDnfHwtfDkRofbY=";
  };

  configurePhase = ''
    runHook preConfigure

    echo '#define GIT_COMMIT_MESSAGE "${finalAttrs.src.rev}"' >> src/git_info.hpp
    echo '#define GIT_COMMIT_DATE "${lib.removePrefix "0-unstable-" finalAttrs.version}"' >> src/git_info.hpp

    runHook postConfigure
  '';

  postPatch = ''
    tar xf ${wayland-protocols.src}
    substituteInPlace Makefile \
      --replace-fail "/usr/share/wayland-protocols/staging/ext-session-lock" "${wayland-protocols.pname}-${wayland-protocols.version}/staging/ext-session-lock" \
      --replace-fail pkg-config ''${PKG_CONFIG}
  '';

  makeFlags = [
    "DESTDIR=${placeholder "out"}"
    "PREFIX="
  ];

  nativeBuildInputs = [ 
    pkg-config
    kdePackages.wayland-protocols
    libevdev
    gtkmm4
    pam
    gtk4-layer-shell
    gtk-session-lock
    wrapGAppsHook4
  ];

  buildInputs = [
    glibmm
    gtkmm4
  ];

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin $out/share
    install -m 755 -D ${finalAttrs.pname} $out/bin/${finalAttrs.pname}
    runHook postInstall
  '';

  postInstall = ''
    wrapProgram $out/bin/${finalAttrs.pname} --prefix LD_LIBRARY_PATH : $out/lib
  '';
})

the latest version
Failed to process .so file
Refer to these two packages syshub sysmenu from same author

Get rid of this; the default install phase will do the right thing, and the one you’ve written omits a lib directory.

The other thing is that your postPatch needs a few more substitutions:

    substituteInPlace src/main.cpp \
      --replace-fail /usr/share/sys64/lock/config.conf $out/share/sys64/lock/config.conf
    substituteInPlace src/window.cpp \
      --replace-fail /usr/share/sys64/lock/style.css $out/share/sys64/lock/style.css

Side note: finalAttrs.pname should never be used in a url (which is effectively what you have by using it in fetchFromGitHub) because if you override pname, the fetcher will break. Just write out the string directly.

thx,Other languages ​​are used to hahaha

it works!
I copied the wrong thing when I borrowed from each other. Sysmenu did not help with the compilation results, so I added installPhase. Since I replaced pkg-conf like syshud, adding installPhase seems to cause a conflict or something. The directory of the configuration file was not successfully replaced.

last version

{
  fetchFromGitHub,
  fetchurl,
  pkg-config,
  stdenv,
  lib,
  libevdev,
  gtkmm4,
  glibmm,
  gtk4-layer-shell,
  git,
  gtk-session-lock,
  pam,
  kdePackages,
  wrapGAppsHook4,
}:
let
  wayland-protocols = rec {
    pname = "wayland-protocols";
    version = "1.38";
    src = fetchurl {
      url = "https://gitlab.freedesktop.org/wayland/${pname}/-/releases/${version}/downloads/${pname}-${version}.tar.xz";
      hash = "sha256-/xcpLAUVnSsgzmys/kLX4xooGY+hQpp2mwOvfDhYHb4=";
    };
  };
in

stdenv.mkDerivation (finalAttrs: {
  pname = "syslock";
  version = "0-unstable-2024-11-17";
  src = fetchFromGitHub {
    owner = "System64fumo";
    repo = finalAttrs.pname;
    rev = "8856cddbf205886a4c3b09f1669c0e6b8e435dbb";
    sha256 = "sha256-YC1G00bSTMyjC0vhZ3yxMzs3Jnb2oDnfHwtfDkRofbY=";
  };

  configurePhase = ''
    runHook preConfigure

    echo '#define GIT_COMMIT_MESSAGE "${finalAttrs.src.rev}"' >> src/git_info.hpp
    echo '#define GIT_COMMIT_DATE "${lib.removePrefix "0-unstable-" finalAttrs.version}"' >> src/git_info.hpp

    runHook postConfigure
  '';

  postPatch = ''
    tar xf ${wayland-protocols.src}
    substituteInPlace Makefile \
      --replace-fail "/usr/share/wayland-protocols/staging/ext-session-lock" "${wayland-protocols.pname}-${wayland-protocols.version}/staging/ext-session-lock" \
      --replace-fail pkg-config ''${PKG_CONFIG}
    substituteInPlace src/main.cpp \
      --replace-fail "/usr/share/sys64/lock/config.conf" "$out/share/sys64/lock/config.conf"
    substituteInPlace src/window.cpp \
      --replace-fail "/usr/share/sys64/lock/style.css" "$out/share/sys64/lock/style.css"
  '';

  makeFlags = [
    "DESTDIR=${placeholder "out"}"
    "PREFIX="
  ];

  nativeBuildInputs = [ 
    pkg-config
    kdePackages.wayland-protocols
    libevdev
    gtkmm4
    pam
    gtk4-layer-shell
    gtk-session-lock
    wrapGAppsHook4
  ];

  buildInputs = [
    glibmm
    gtkmm4
  ];

  postInstall = ''
    wrapProgram $out/bin/syslock --prefix LD_LIBRARY_PATH : $out/lib
  '';
})