Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 config, 3 lib, 4 stdenv, 5 fetchurl, 6 fetchpatch, 7 atk, 8 buildPackages, 9 cairo, 10 cups, 11 gdk-pixbuf, 12 gettext, 13 glib, 14 gobject-introspection, 15 libXcomposite, 16 libXcursor, 17 libXdamage, 18 libXi, 19 libXinerama, 20 libXrandr, 21 libXrender, 22 pango, 23 perl, 24 pkg-config, 25 replaceVars, 26 testers, 27 gdktarget ? if stdenv.hostPlatform.isDarwin then "quartz" else "x11", 28 cupsSupport ? config.gtk2.cups or stdenv.hostPlatform.isLinux, 29 xineramaSupport ? stdenv.hostPlatform.isLinux, 30}: 31 32let 33 gtkCleanImmodulesCache = replaceVars ./hooks/clean-immodules-cache.sh { 34 gtk_module_path = "gtk-2.0"; 35 gtk_binary_version = "2.10.0"; 36 }; 37in 38stdenv.mkDerivation (finalAttrs: { 39 pname = "gtk+"; 40 version = "2.24.33"; 41 42 src = fetchurl { 43 url = "mirror://gnome/sources/gtk+/2.24/gtk+-${finalAttrs.version}.tar.xz"; 44 hash = "sha256-rCrHV/WULTGKMRpUsMgLXvKV8pnCpzxjL2v7H/Scxto="; 45 }; 46 47 outputs = [ 48 "out" 49 "dev" 50 "devdoc" 51 ]; 52 outputBin = "dev"; 53 54 setupHooks = [ 55 ./hooks/drop-icon-theme-cache.sh 56 gtkCleanImmodulesCache 57 ]; 58 59 nativeBuildInputs = finalAttrs.setupHooks ++ [ 60 gdk-pixbuf 61 gettext 62 gobject-introspection 63 perl 64 pkg-config 65 ]; 66 67 patches = [ 68 ./patches/2.0-immodules.cache.patch 69 ./patches/gtk2-theme-paths.patch 70 (fetchpatch { 71 # https://gitlab.gnome.org/GNOME/gtk/-/issues/6786 72 name = "CVE-2024-6655.patch"; 73 url = "https://gitlab.gnome.org/GNOME/gtk/-/commit/3bbf0b6176d42836d23c36a6ac410e807ec0a7a7.patch"; 74 hash = "sha256-mstOPk9NNpUwScrdEbvGhmAv8jlds3SBdj53T0q33vM="; 75 }) 76 ] 77 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 78 ./patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch 79 ./patches/2.0-darwin-x11.patch 80 # Fixes an incompatible function pointer conversion and implicit int errors with clang 16. 81 ./patches/2.0-clang.patch 82 ]; 83 84 propagatedBuildInputs = [ 85 atk 86 cairo 87 gdk-pixbuf 88 glib 89 pango 90 ] 91 ++ lib.optionals (stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) [ 92 libXcomposite 93 libXcursor 94 libXi 95 libXrandr 96 libXrender 97 ] 98 ++ lib.optional xineramaSupport libXinerama 99 ++ lib.optional cupsSupport cups 100 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 101 libXdamage 102 ]; 103 104 preConfigure = lib.optionalString ( 105 stdenv.hostPlatform.isDarwin && lib.versionAtLeast stdenv.hostPlatform.darwinMinVersion "11" 106 ) "MACOSX_DEPLOYMENT_TARGET=10.16"; 107 108 configureFlags = [ 109 "--sysconfdir=/etc" 110 "--with-gdktarget=${gdktarget}" 111 "--with-xinput=yes" 112 ] 113 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 114 "--disable-glibtest" 115 "--disable-introspection" 116 "--disable-visibility" 117 ] 118 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ 119 "ac_cv_path_GTK_UPDATE_ICON_CACHE=${buildPackages.gtk2}/bin/gtk-update-icon-cache" 120 "ac_cv_path_GDK_PIXBUF_CSOURCE=${buildPackages.gdk-pixbuf.dev}/bin/gdk-pixbuf-csource" 121 ]; 122 123 env = lib.optionalAttrs stdenv.cc.isGNU { 124 NIX_CFLAGS_COMPILE = toString [ 125 "-Wno-error=implicit-int" 126 "-Wno-error=incompatible-pointer-types" 127 ]; 128 }; 129 130 enableParallelBuilding = true; 131 132 installFlags = [ 133 "sysconfdir=${placeholder "out"}/etc" 134 ]; 135 136 doCheck = false; # needs X11 137 138 postInstall = '' 139 moveToOutput share/gtk-2.0/demo "$devdoc" 140 # The updater is needed for nixos env and it's tiny. 141 moveToOutput bin/gtk-update-icon-cache "$out" 142 ''; 143 144 passthru = { 145 gtkExeEnvPostBuild = '' 146 rm $out/lib/gtk-2.0/2.10.0/immodules.cache 147 $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 148 ''; # workaround for bug of nix-mode for Emacs */ ''; 149 inherit gdktarget; 150 tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; 151 }; 152 153 meta = { 154 homepage = "https://www.gtk.org/"; 155 description = "Multi-platform toolkit for creating graphical user interfaces"; 156 longDescription = '' 157 GTK is a highly usable, feature rich toolkit for creating graphical user 158 interfaces which boasts cross platform compatibility and an easy to use 159 API. GTK it is written in C, but has bindings to many other popular 160 programming languages such as C++, Python and C# among others. GTK is 161 licensed under the GNU LGPL 2.1 allowing development of both free and 162 proprietary software with GTK without any license fees or royalties. 163 ''; 164 changelog = "https://gitlab.gnome.org/GNOME/gtk/-/raw/${finalAttrs.version}/NEWS"; 165 license = lib.licenses.lgpl2Plus; 166 maintainers = with lib.maintainers; [ 167 lovek323 168 raskin 169 ]; 170 platforms = lib.platforms.all; 171 pkgConfigModules = [ 172 "gdk-2.0" 173 "gtk+-2.0" 174 ] 175 ++ lib.optionals (gdktarget == "x11") [ 176 "gdk-x11-2.0" 177 "gtk+-x11-2.0" 178 ]; 179 }; 180})