13 , gobject-introspection
28 , gdktarget ? if stdenv.hostPlatform.isDarwin then "quartz" else "x11"
29 , cupsSupport ? config.gtk2.cups or stdenv.hostPlatform.isLinux
30 , xineramaSupport ? stdenv.hostPlatform.isLinux
34 gtkCleanImmodulesCache = substituteAll {
35 src = ./hooks/clean-immodules-cache.sh;
36 gtk_module_path = "gtk-2.0";
37 gtk_binary_version = "2.10.0";
40 stdenv.mkDerivation (finalAttrs: {
45 url = "mirror://gnome/sources/gtk+/2.24/gtk+-${finalAttrs.version}.tar.xz";
46 hash = "sha256-rCrHV/WULTGKMRpUsMgLXvKV8pnCpzxjL2v7H/Scxto=";
49 outputs = [ "out" "dev" "devdoc" ];
53 ./hooks/drop-icon-theme-cache.sh
54 gtkCleanImmodulesCache
57 nativeBuildInputs = finalAttrs.setupHooks ++ [
65 ./patches/2.0-immodules.cache.patch
66 ./patches/gtk2-theme-paths.patch
68 # https://gitlab.gnome.org/GNOME/gtk/-/issues/6786
69 name = "CVE-2024-6655.patch";
70 url = "https://gitlab.gnome.org/GNOME/gtk/-/commit/3bbf0b6176d42836d23c36a6ac410e807ec0a7a7.patch";
71 hash = "sha256-mstOPk9NNpUwScrdEbvGhmAv8jlds3SBdj53T0q33vM=";
73 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
74 ./patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch
75 ./patches/2.0-darwin-x11.patch
76 # Fixes an incompatible function pointer conversion and implicit int errors with clang 16.
77 ./patches/2.0-clang.patch
80 propagatedBuildInputs = [
86 ] ++ lib.optionals (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) [
92 ] ++ lib.optional xineramaSupport libXinerama
93 ++ lib.optional cupsSupport cups
94 ++ lib.optionals stdenv.hostPlatform.isDarwin [
101 lib.optionalString (stdenv.hostPlatform.isDarwin
102 && lib.versionAtLeast
103 stdenv.hostPlatform.darwinMinVersion "11")
104 "MACOSX_DEPLOYMENT_TARGET=10.16";
108 "--with-gdktarget=${gdktarget}"
110 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
112 "--disable-introspection"
113 "--disable-visibility"
114 ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
115 "ac_cv_path_GTK_UPDATE_ICON_CACHE=${buildPackages.gtk2}/bin/gtk-update-icon-cache"
116 "ac_cv_path_GDK_PIXBUF_CSOURCE=${buildPackages.gdk-pixbuf.dev}/bin/gdk-pixbuf-csource"
119 env = lib.optionalAttrs stdenv.cc.isGNU {
120 NIX_CFLAGS_COMPILE = toString [
121 "-Wno-error=implicit-int"
122 "-Wno-error=incompatible-pointer-types"
126 enableParallelBuilding = true;
129 "sysconfdir=${placeholder "out"}/etc"
132 doCheck = false; # needs X11
135 moveToOutput share/gtk-2.0/demo "$devdoc"
136 # The updater is needed for nixos env and it's tiny.
137 moveToOutput bin/gtk-update-icon-cache "$out"
141 gtkExeEnvPostBuild = ''
142 rm $out/lib/gtk-2.0/2.10.0/immodules.cache
143 $out/bin/gtk-query-immodules-2.0 $out/lib/gtk-2.0/2.10.0/immodules/*.so > $out/lib/gtk-2.0/2.10.0/immodules.cache
144 ''; # workaround for bug of nix-mode for Emacs */ '';
146 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
150 homepage = "https://www.gtk.org/";
151 description = "Multi-platform toolkit for creating graphical user interfaces";
153 GTK is a highly usable, feature rich toolkit for creating graphical user
154 interfaces which boasts cross platform compatibility and an easy to use
155 API. GTK it is written in C, but has bindings to many other popular
156 programming languages such as C++, Python and C# among others. GTK is
157 licensed under the GNU LGPL 2.1 allowing development of both free and
158 proprietary software with GTK without any license fees or royalties.
160 changelog = "https://gitlab.gnome.org/GNOME/gtk/-/raw/${finalAttrs.version}/NEWS";
161 license = lib.licenses.lgpl2Plus;
162 maintainers = with lib.maintainers; [ lovek323 raskin ];
163 platforms = lib.platforms.all;
167 ] ++ lib.optionals (gdktarget == "x11") [