forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / development / libraries / gtk / 2.x.nix
blob7d11b671b1b7c667737ff28bdf422cca2cdc9bda
1 { config
2 , lib
3 , stdenv
4 , fetchurl
5 , fetchpatch
6 , atk
7 , buildPackages
8 , cairo
9 , cups
10 , gdk-pixbuf
11 , gettext
12 , glib
13 , gobject-introspection
14 , libXcomposite
15 , libXcursor
16 , libXdamage
17 , libXi
18 , libXinerama
19 , libXrandr
20 , libXrender
21 , pango
22 , perl
23 , pkg-config
24 , substituteAll
25 , testers
26 , AppKit
27 , Cocoa
28 , gdktarget ? if stdenv.hostPlatform.isDarwin then "quartz" else "x11"
29 , cupsSupport ? config.gtk2.cups or stdenv.hostPlatform.isLinux
30 , xineramaSupport ? stdenv.hostPlatform.isLinux
33 let
34   gtkCleanImmodulesCache = substituteAll {
35     src = ./hooks/clean-immodules-cache.sh;
36     gtk_module_path = "gtk-2.0";
37     gtk_binary_version = "2.10.0";
38   };
40 stdenv.mkDerivation (finalAttrs: {
41   pname = "gtk+";
42   version = "2.24.33";
44   src = fetchurl {
45     url = "mirror://gnome/sources/gtk+/2.24/gtk+-${finalAttrs.version}.tar.xz";
46     hash = "sha256-rCrHV/WULTGKMRpUsMgLXvKV8pnCpzxjL2v7H/Scxto=";
47   };
49   outputs = [ "out" "dev" "devdoc" ];
50   outputBin = "dev";
52   setupHooks =  [
53     ./hooks/drop-icon-theme-cache.sh
54     gtkCleanImmodulesCache
55   ];
57   nativeBuildInputs = finalAttrs.setupHooks ++ [
58     gettext
59     gobject-introspection
60     perl
61     pkg-config
62   ];
64   patches = [
65     ./patches/2.0-immodules.cache.patch
66     ./patches/gtk2-theme-paths.patch
67     (fetchpatch {
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=";
72     })
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
78   ];
80   propagatedBuildInputs = [
81     atk
82     cairo
83     gdk-pixbuf
84     glib
85     pango
86   ] ++ lib.optionals (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) [
87     libXcomposite
88     libXcursor
89     libXi
90     libXrandr
91     libXrender
92   ] ++ lib.optional xineramaSupport libXinerama
93   ++ lib.optional cupsSupport cups
94   ++ lib.optionals stdenv.hostPlatform.isDarwin [
95     libXdamage
96     AppKit
97     Cocoa
98   ];
100   preConfigure =
101     lib.optionalString (stdenv.hostPlatform.isDarwin
102                         && lib.versionAtLeast
103                           stdenv.hostPlatform.darwinMinVersion "11")
104       "MACOSX_DEPLOYMENT_TARGET=10.16";
106   configureFlags = [
107     "--sysconfdir=/etc"
108     "--with-gdktarget=${gdktarget}"
109     "--with-xinput=yes"
110   ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
111     "--disable-glibtest"
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"
117   ];
119   env = lib.optionalAttrs stdenv.cc.isGNU {
120     NIX_CFLAGS_COMPILE = toString [
121       "-Wno-error=implicit-int"
122       "-Wno-error=incompatible-pointer-types"
123     ];
124   };
126   enableParallelBuilding = true;
128   installFlags = [
129     "sysconfdir=${placeholder "out"}/etc"
130   ];
132   doCheck = false; # needs X11
134   postInstall = ''
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"
138   '';
140   passthru = {
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 */ '';
145     inherit gdktarget;
146     tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage;
147   };
149   meta = {
150     homepage = "https://www.gtk.org/";
151     description = "Multi-platform toolkit for creating graphical user interfaces";
152     longDescription = ''
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.
159     '';
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;
164     pkgConfigModules = [
165       "gdk-2.0"
166       "gtk+-2.0"
167     ] ++ lib.optionals (gdktarget == "x11") [
168       "gdk-x11-2.0"
169       "gtk+-x11-2.0"
170     ];
171   };