How to build emacs using newer version of gtk3

You may want to try this nuclear solution

{
  programs.emacs = {
    enable = true;
    package = with import pkgs.path {
      system = "x86_64-linux";
      overlays = [
        (final: prev: {
          gtk3 = prev.gtk3.overrideAttrs {
            src = final.fetchFromGitLab {
              domain = "gitlab.gnome.org";
              owner = "GNOME";
              repo = "gtk";
              rev =
                "6bb28fca797882a238b41fdaf88dfea8f6b2dfc5"; # 2024.11.16 gtk-3-24 branch
              hash = "sha256-k7G0a/W5LCw/Yto20CYwUZoVh6ebdYIji00JS3RCaQ8=";
            };
          };
        })
      ];
    };
      emacs30-pgtk; # or (emacsPackagesFor emacs30-pgtk).withPackages (epkgs: []);
  };
}

The main point is, though not advised, you can have:

let
  myPkgs = import pkgs.path {
    system = "x86_64-linux";
    overlays = [ ... ];
  };
in ...
1 Like