14 gobject-introspection,
29 gdktarget ? if stdenv.hostPlatform.isDarwin then "quartz" else "x11",
30 cupsSupport ? config.gtk2.cups or stdenv.hostPlatform.isLinux,
31 xineramaSupport ? stdenv.hostPlatform.isLinux,
35 gtkCleanImmodulesCache = substituteAll {
36 src = ./hooks/clean-immodules-cache.sh;
37 gtk_module_path = "gtk-2.0";
38 gtk_binary_version = "2.10.0";
41 stdenv.mkDerivation (finalAttrs: {
46 url = "mirror://gnome/sources/gtk+/2.24/gtk+-${finalAttrs.version}.tar.xz";
47 hash = "sha256-rCrHV/WULTGKMRpUsMgLXvKV8pnCpzxjL2v7H/Scxto=";
58 ./hooks/drop-icon-theme-cache.sh
59 gtkCleanImmodulesCache
62 nativeBuildInputs = finalAttrs.setupHooks ++ [
71 ./patches/2.0-immodules.cache.patch
72 ./patches/gtk2-theme-paths.patch
74 # https://gitlab.gnome.org/GNOME/gtk/-/issues/6786
75 name = "CVE-2024-6655.patch";
76 url = "https://gitlab.gnome.org/GNOME/gtk/-/commit/3bbf0b6176d42836d23c36a6ac410e807ec0a7a7.patch";
77 hash = "sha256-mstOPk9NNpUwScrdEbvGhmAv8jlds3SBdj53T0q33vM=";
80 ++ lib.optionals stdenv.hostPlatform.isDarwin [
81 ./patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch
82 ./patches/2.0-darwin-x11.patch
83 # Fixes an incompatible function pointer conversion and implicit int errors with clang 16.
84 ./patches/2.0-clang.patch
87 propagatedBuildInputs =
95 ++ lib.optionals (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) [
102 ++ lib.optional xineramaSupport libXinerama
103 ++ lib.optional cupsSupport cups
104 ++ lib.optionals stdenv.hostPlatform.isDarwin [
110 preConfigure = lib.optionalString (
111 stdenv.hostPlatform.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11"
112 ) "MACOSX_DEPLOYMENT_TARGET=10.16";
117 "--with-gdktarget=${gdktarget}"
120 ++ lib.optionals stdenv.hostPlatform.isDarwin [
122 "--disable-introspection"
123 "--disable-visibility"
125 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
126 "ac_cv_path_GTK_UPDATE_ICON_CACHE=${buildPackages.gtk2}/bin/gtk-update-icon-cache"
127 "ac_cv_path_GDK_PIXBUF_CSOURCE=${buildPackages.gdk-pixbuf.dev}/bin/gdk-pixbuf-csource"
130 env = lib.optionalAttrs stdenv.cc.isGNU {
131 NIX_CFLAGS_COMPILE = toString [
132 "-Wno-error=implicit-int"
133 "-Wno-error=incompatible-pointer-types"
137 enableParallelBuilding = true;
140 "sysconfdir=${placeholder "out"}/etc"
143 doCheck = false; # needs X11
146 moveToOutput share/gtk-2.0/demo "$devdoc"
147 # The updater is needed for nixos env and it's tiny.
148 moveToOutput bin/gtk-update-icon-cache "$out"
152 gtkExeEnvPostBuild = ''
153 rm $out/lib/gtk-2.0/2.10.0/immodules.cache
154 $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
155 ''; # workaround for bug of nix-mode for Emacs */ '';
157 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
161 homepage = "https://www.gtk.org/";
162 description = "Multi-platform toolkit for creating graphical user interfaces";
164 GTK is a highly usable, feature rich toolkit for creating graphical user
165 interfaces which boasts cross platform compatibility and an easy to use
166 API. GTK it is written in C, but has bindings to many other popular
167 programming languages such as C++, Python and C# among others. GTK is
168 licensed under the GNU LGPL 2.1 allowing development of both free and
169 proprietary software with GTK without any license fees or royalties.
171 changelog = "https://gitlab.gnome.org/GNOME/gtk/-/raw/${finalAttrs.version}/NEWS";
172 license = lib.licenses.lgpl2Plus;
173 maintainers = with lib.maintainers; [
177 platforms = lib.platforms.all;
183 ++ lib.optionals (gdktarget == "x11") [