diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/gtk')
13 files changed, 999 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/gtk/2.x.nix b/nixpkgs/pkgs/development/libraries/gtk/2.x.nix new file mode 100644 index 000000000000..539cfc37051b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/2.x.nix @@ -0,0 +1,156 @@ +{ config +, lib +, stdenv +, fetchurl +, atk +, buildPackages +, cairo +, cups +, gdk-pixbuf +, gettext +, glib +, gobject-introspection +, libXcomposite +, libXcursor +, libXdamage +, libXi +, libXinerama +, libXrandr +, libXrender +, pango +, perl +, pkg-config +, substituteAll +, testers +, AppKit +, Cocoa +, gdktarget ? if stdenv.isDarwin then "quartz" else "x11" +, cupsSupport ? config.gtk2.cups or stdenv.isLinux +, xineramaSupport ? stdenv.isLinux +}: + +let + gtkCleanImmodulesCache = substituteAll { + src = ./hooks/clean-immodules-cache.sh; + gtk_module_path = "gtk-2.0"; + gtk_binary_version = "2.10.0"; + }; +in +stdenv.mkDerivation (finalAttrs: { + pname = "gtk+"; + version = "2.24.33"; + + src = fetchurl { + url = "mirror://gnome/sources/gtk+/2.24/gtk+-${finalAttrs.version}.tar.xz"; + hash = "sha256-rCrHV/WULTGKMRpUsMgLXvKV8pnCpzxjL2v7H/Scxto="; + }; + + outputs = [ "out" "dev" "devdoc" ]; + outputBin = "dev"; + + setupHooks = [ + ./hooks/drop-icon-theme-cache.sh + gtkCleanImmodulesCache + ]; + + nativeBuildInputs = finalAttrs.setupHooks ++ [ + gettext + gobject-introspection + perl + pkg-config + ]; + + patches = [ + ./patches/2.0-immodules.cache.patch + ./patches/gtk2-theme-paths.patch + ] ++ lib.optionals stdenv.isDarwin [ + ./patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch + ./patches/2.0-darwin-x11.patch + ]; + + propagatedBuildInputs = [ + atk + cairo + gdk-pixbuf + glib + pango + ] ++ lib.optionals (stdenv.isLinux || stdenv.isDarwin) [ + libXcomposite + libXcursor + libXi + libXrandr + libXrender + ] ++ lib.optional xineramaSupport libXinerama + ++ lib.optional cupsSupport cups + ++ lib.optionals stdenv.isDarwin [ + libXdamage + AppKit + Cocoa + ]; + + preConfigure = + lib.optionalString (stdenv.isDarwin + && lib.versionAtLeast + stdenv.hostPlatform.darwinMinVersion "11") + "MACOSX_DEPLOYMENT_TARGET=10.16"; + + configureFlags = [ + "--sysconfdir=/etc" + "--with-gdktarget=${gdktarget}" + "--with-xinput=yes" + ] ++ lib.optionals stdenv.isDarwin [ + "--disable-glibtest" + "--disable-introspection" + "--disable-visibility" + ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "ac_cv_path_GTK_UPDATE_ICON_CACHE=${buildPackages.gtk2}/bin/gtk-update-icon-cache" + "ac_cv_path_GDK_PIXBUF_CSOURCE=${buildPackages.gdk-pixbuf.dev}/bin/gdk-pixbuf-csource" + ]; + + enableParallelBuilding = true; + + installFlags = [ + "sysconfdir=${placeholder "out"}/etc" + ]; + + doCheck = false; # needs X11 + + postInstall = '' + moveToOutput share/gtk-2.0/demo "$devdoc" + # The updater is needed for nixos env and it's tiny. + moveToOutput bin/gtk-update-icon-cache "$out" + ''; + + passthru = { + gtkExeEnvPostBuild = '' + rm $out/lib/gtk-2.0/2.10.0/immodules.cache + $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 + ''; # workaround for bug of nix-mode for Emacs */ ''; + inherit gdktarget; + tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + }; + + meta = { + homepage = "https://www.gtk.org/"; + description = "A multi-platform toolkit for creating graphical user interfaces"; + longDescription = '' + GTK is a highly usable, feature rich toolkit for creating graphical user + interfaces which boasts cross platform compatibility and an easy to use + API. GTK it is written in C, but has bindings to many other popular + programming languages such as C++, Python and C# among others. GTK is + licensed under the GNU LGPL 2.1 allowing development of both free and + proprietary software with GTK without any license fees or royalties. + ''; + changelog = "https://gitlab.gnome.org/GNOME/gtk/-/raw/${finalAttrs.version}/NEWS"; + license = lib.licenses.lgpl2Plus; + maintainers = with lib.maintainers; [ lovek323 raskin ]; + platforms = lib.platforms.all; + pkgConfigModules = [ + "gdk-2.0" + "gtk+-2.0" + ] ++ lib.optionals (gdktarget == "x11") [ + "gdk-x11-2.0" + "gtk+-x11-2.0" + ]; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/gtk/3.x.nix b/nixpkgs/pkgs/development/libraries/gtk/3.x.nix new file mode 100644 index 000000000000..27afba7833e8 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/3.x.nix @@ -0,0 +1,269 @@ +{ lib +, stdenv +, substituteAll +, fetchurl +, pkg-config +, gettext +, docbook-xsl-nons +, docbook_xml_dtd_43 +, gtk-doc +, meson +, mesonEmulatorHook +, ninja +, python3 +, makeWrapper +, shared-mime-info +, isocodes +, expat +, glib +, cairo +, pango +, gdk-pixbuf +, atk +, at-spi2-atk +, gobject-introspection +, buildPackages +, withIntrospection ? lib.meta.availableOn stdenv.hostPlatform gobject-introspection && stdenv.hostPlatform.emulatorAvailable buildPackages +, compileSchemas ? stdenv.hostPlatform.emulatorAvailable buildPackages +, fribidi +, xorg +, libepoxy +, libxkbcommon +, libxml2 +, gmp +, gnome +, gsettings-desktop-schemas +, sassc +, trackerSupport ? stdenv.isLinux && (stdenv.buildPlatform == stdenv.hostPlatform) +, tracker +, x11Support ? stdenv.isLinux +, waylandSupport ? stdenv.isLinux +, libGL +, wayland +, wayland-protocols +, xineramaSupport ? stdenv.isLinux +, cupsSupport ? stdenv.isLinux +, cups +, AppKit +, Cocoa +, QuartzCore +, broadwaySupport ? true +, wayland-scanner +, testers +}: + +let + + gtkCleanImmodulesCache = substituteAll { + src = ./hooks/clean-immodules-cache.sh; + gtk_module_path = "gtk-3.0"; + gtk_binary_version = "3.0.0"; + }; + +in + +stdenv.mkDerivation (finalAttrs: { + pname = "gtk+3"; + version = "3.24.38"; + + outputs = [ "out" "dev" ] ++ lib.optional withIntrospection "devdoc"; + outputBin = "dev"; + + setupHooks = [ + ./hooks/drop-icon-theme-cache.sh + gtkCleanImmodulesCache + ]; + + src = let + inherit (finalAttrs) version; + in fetchurl { + url = "mirror://gnome/sources/gtk+/${lib.versions.majorMinor version}/gtk+-${version}.tar.xz"; + sha256 = "sha256-zhHezwGLJb3YUFVEpPhyQoVOyIvgVNmt5fOiBETdjuc="; + }; + + patches = [ + ./patches/3.0-immodules.cache.patch + ./patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch + ] ++ lib.optionals stdenv.isDarwin [ + # X11 module requires <gio/gdesktopappinfo.h> which is not installed on Darwin + # let’s drop that dependency in similar way to how other parts of the library do it + # e.g. https://gitlab.gnome.org/GNOME/gtk/blob/3.24.4/gtk/gtk-launch.c#L31-33 + # https://gitlab.gnome.org/GNOME/gtk/merge_requests/536 + ./patches/3.0-darwin-x11.patch + ]; + + depsBuildBuild = [ + pkg-config + ]; + nativeBuildInputs = [ + gettext + makeWrapper + meson + ninja + pkg-config + python3 + sassc + gdk-pixbuf + ] ++ finalAttrs.setupHooks ++ lib.optionals withIntrospection [ + gobject-introspection + docbook_xml_dtd_43 + docbook-xsl-nons + gtk-doc + # For xmllint + libxml2 + ] ++ lib.optionals ((withIntrospection || compileSchemas) && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + mesonEmulatorHook + ] ++ lib.optionals waylandSupport [ + wayland-scanner + ]; + + buildInputs = [ + libxkbcommon + (libepoxy.override { inherit x11Support; }) + isocodes + ] ++ lib.optionals stdenv.isDarwin [ + AppKit + ] ++ lib.optionals trackerSupport [ + tracker + ]; + #TODO: colord? + + propagatedBuildInputs = with xorg; [ + at-spi2-atk + atk + cairo + expat + fribidi + gdk-pixbuf + glib + gsettings-desktop-schemas + libICE + libSM + libXcomposite + libXcursor + libXdamage + libXfixes + libXi + libXrandr + libXrender + pango + ] ++ lib.optionals stdenv.isDarwin [ + # explicitly propagated, always needed + Cocoa + QuartzCore + ] ++ lib.optionals waylandSupport [ + libGL + wayland + wayland-protocols + ] ++ lib.optionals xineramaSupport [ + libXinerama + ] ++ lib.optionals cupsSupport [ + cups + ]; + + mesonFlags = [ + "-Dgtk_doc=${lib.boolToString withIntrospection}" + "-Dtests=false" + "-Dtracker3=${lib.boolToString trackerSupport}" + "-Dbroadway_backend=${lib.boolToString broadwaySupport}" + "-Dx11_backend=${lib.boolToString x11Support}" + "-Dquartz_backend=${lib.boolToString (stdenv.isDarwin && !x11Support)}" + "-Dintrospection=${lib.boolToString withIntrospection}" + ]; + + doCheck = false; # needs X11 + + separateDebugInfo = stdenv.isLinux; + + # These are the defines that'd you'd get with --enable-debug=minimum (default). + # See: https://developer.gnome.org/gtk3/stable/gtk-building.html#extra-configuration-options + env.NIX_CFLAGS_COMPILE = "-DG_ENABLE_DEBUG -DG_DISABLE_CAST_CHECKS"; + + postPatch = '' + # See https://github.com/NixOS/nixpkgs/issues/132259 + substituteInPlace meson.build \ + --replace "x11_enabled = false" "" + + # this conditional gates the installation of share/gsettings-schemas/.../glib-2.0/schemas/gschemas.compiled. + substituteInPlace meson.build \ + --replace 'if not meson.is_cross_build()' 'if ${lib.boolToString compileSchemas}' + + files=( + build-aux/meson/post-install.py + demos/gtk-demo/geninclude.py + gdk/broadway/gen-c-array.py + gdk/gen-gdk-gresources-xml.py + gtk/cursor/dnd-copy.png + gtk/gen-gtk-gresources-xml.py + gtk/gen-rc.py + gtk/gentypefuncs.py + ) + + chmod +x ''${files[@]} + patchShebangs ''${files[@]} + ''; + + postInstall = lib.optionalString (!stdenv.isDarwin) '' + # The updater is needed for nixos env and it's tiny. + moveToOutput bin/gtk-update-icon-cache "$out" + # Launcher + moveToOutput bin/gtk-launch "$out" + # Broadway daemon + moveToOutput bin/broadwayd "$out" + + # TODO: patch glib directly + for f in $dev/bin/gtk-encode-symbolic-svg; do + wrapProgram $f --prefix XDG_DATA_DIRS : "${shared-mime-info}/share" + done + '' + lib.optionalString (stdenv.buildPlatform == stdenv.hostPlatform) '' + GTK_PATH="''${out:?}/lib/gtk-3.0/3.0.0/immodules/" ''${dev:?}/bin/gtk-query-immodules-3.0 > "''${out:?}/lib/gtk-3.0/3.0.0/immodules.cache" + ''; + + # Wrap demos + postFixup = lib.optionalString (!stdenv.isDarwin) '' + demos=(gtk3-demo gtk3-demo-application gtk3-icon-browser gtk3-widget-factory) + + for program in ''${demos[@]}; do + wrapProgram $dev/bin/$program \ + --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:$out/share/gsettings-schemas/${finalAttrs.pname}-${finalAttrs.version}" + done + '' + lib.optionalString stdenv.isDarwin '' + # a comment created a cycle between outputs + sed '/^# ModulesPath =/d' -i "$out"/lib/gtk-*/*/immodules.cache + ''; + + passthru = { + updateScript = gnome.updateScript { + packageName = "gtk+"; + attrPath = "gtk3"; + freeze = true; + }; + tests.pkg-config = testers.testMetaPkgConfig finalAttrs.finalPackage; + }; + + meta = with lib; { + description = "A multi-platform toolkit for creating graphical user interfaces"; + longDescription = '' + GTK is a highly usable, feature rich toolkit for creating + graphical user interfaces which boasts cross platform + compatibility and an easy to use API. GTK it is written in C, + but has bindings to many other popular programming languages + such as C++, Python and C# among others. GTK is licensed + under the GNU LGPL 2.1 allowing development of both free and + proprietary software with GTK without any license fees or + royalties. + ''; + homepage = "https://www.gtk.org/"; + license = licenses.lgpl2Plus; + maintainers = with maintainers; [ raskin ] ++ teams.gnome.members; + pkgConfigModules = [ + "gdk-3.0" + "gtk+-3.0" + ] ++ lib.optionals x11Support [ + "gdk-x11-3.0" + "gtk+-x11-3.0" + ]; + platforms = platforms.all; + changelog = "https://gitlab.gnome.org/GNOME/gtk/-/raw/${version}/NEWS"; + }; +}) diff --git a/nixpkgs/pkgs/development/libraries/gtk/4.x.nix b/nixpkgs/pkgs/development/libraries/gtk/4.x.nix new file mode 100644 index 000000000000..0503ac199f90 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/4.x.nix @@ -0,0 +1,277 @@ +{ lib +, stdenv +, buildPackages +, substituteAll +, fetchurl +, pkg-config +, gettext +, graphene +, gi-docgen +, meson +, mesonEmulatorHook +, ninja +, python3 +, makeWrapper +, shared-mime-info +, isocodes +, glib +, cairo +, pango +, pandoc +, gdk-pixbuf +, gobject-introspection +, fribidi +, harfbuzz +, xorg +, libepoxy +, libxkbcommon +, libpng +, libtiff +, libjpeg +, libxml2 +, gnome +, gsettings-desktop-schemas +, gst_all_1 +, sassc +, trackerSupport ? stdenv.isLinux +, tracker +, x11Support ? stdenv.isLinux +, waylandSupport ? stdenv.isLinux +, libGL +# experimental and can cause crashes in inspector +, vulkanSupport ? false +, vulkan-loader +, vulkan-headers +, wayland +, wayland-protocols +, wayland-scanner +, xineramaSupport ? stdenv.isLinux +, cupsSupport ? stdenv.isLinux +, compileSchemas ? stdenv.hostPlatform.emulatorAvailable buildPackages +, cups +, AppKit +, Cocoa +, libexecinfo +, broadwaySupport ? true +}: + +let + + gtkCleanImmodulesCache = substituteAll { + src = ./hooks/clean-immodules-cache.sh; + gtk_module_path = "gtk-4.0"; + gtk_binary_version = "4.0.0"; + }; + +in + +stdenv.mkDerivation rec { + pname = "gtk4"; + version = "4.10.4"; + + outputs = [ "out" "dev" ] ++ lib.optionals x11Support [ "devdoc" ]; + outputBin = "dev"; + + setupHooks = [ + ./hooks/drop-icon-theme-cache.sh + gtkCleanImmodulesCache + ]; + + src = fetchurl { + url = "mirror://gnome/sources/gtk/${lib.versions.majorMinor version}/gtk-${version}.tar.xz"; + sha256 = "dyVABILgaF4oJl4ibGKEf05zz8qem0FqxYOCB/U3eiQ="; + }; + + patches = [ + # https://github.com/NixOS/nixpkgs/pull/218143#issuecomment-1501059486 + ./patches/4.0-fix-darwin-build.patch + ]; + + depsBuildBuild = [ + pkg-config + ]; + + nativeBuildInputs = [ + gettext + gobject-introspection + makeWrapper + meson + ninja + pkg-config + python3 + sassc + gi-docgen + libxml2 # for xmllint + ] ++ lib.optionals (compileSchemas && !stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ + mesonEmulatorHook + ] ++ lib.optionals waylandSupport [ + wayland-scanner + ] ++ setupHooks; + + buildInputs = [ + libxkbcommon + libpng + libtiff + libjpeg + (libepoxy.override { inherit x11Support; }) + isocodes + ] ++ lib.optionals vulkanSupport [ + vulkan-headers + ] ++ [ + gst_all_1.gst-plugins-base + gst_all_1.gst-plugins-bad + fribidi + harfbuzz + ] ++ (with xorg; [ + libICE + libSM + libXcursor + libXdamage + libXi + libXrandr + libXrender + ]) ++ lib.optionals stdenv.isDarwin [ + AppKit + ] ++ lib.optionals trackerSupport [ + tracker + ] ++ lib.optionals waylandSupport [ + libGL + wayland + wayland-protocols + ] ++ lib.optionals xineramaSupport [ + xorg.libXinerama + ] ++ lib.optionals cupsSupport [ + cups + ] ++ lib.optionals stdenv.isDarwin [ + Cocoa + ] ++ lib.optionals stdenv.hostPlatform.isMusl [ + libexecinfo + ]; + #TODO: colord? + + propagatedBuildInputs = [ + # Required by pkg-config files. + cairo + gdk-pixbuf + glib + graphene + pango + ] ++ lib.optionals waylandSupport [ + wayland + ] ++ lib.optionals vulkanSupport [ + vulkan-loader + ] ++ [ + # Required for GSettings schemas at runtime. + # Will be picked up by wrapGAppsHook. + gsettings-desktop-schemas + ]; + + mesonFlags = [ + # ../docs/tools/shooter.c:4:10: fatal error: 'cairo-xlib.h' file not found + "-Dgtk_doc=${lib.boolToString x11Support}" + "-Dbuild-tests=false" + "-Dtracker=${if trackerSupport then "enabled" else "disabled"}" + "-Dbroadway-backend=${lib.boolToString broadwaySupport}" + ] ++ lib.optionals vulkanSupport [ + "-Dvulkan=enabled" + ] ++ lib.optionals (!cupsSupport) [ + "-Dprint-cups=disabled" + ] ++ lib.optionals (stdenv.isDarwin && !stdenv.isAarch64) [ + "-Dmedia-gstreamer=disabled" # requires gstreamer-gl + ] ++ lib.optionals (!x11Support) [ + "-Dx11-backend=false" + ]; + + doCheck = false; # needs X11 + + separateDebugInfo = stdenv.isLinux; + + # These are the defines that'd you'd get with --enable-debug=minimum (default). + # See: https://developer.gnome.org/gtk3/stable/gtk-building.html#extra-configuration-options + env = { + NIX_CFLAGS_COMPILE = "-DG_ENABLE_DEBUG -DG_DISABLE_CAST_CHECKS"; + } // lib.optionalAttrs stdenv.hostPlatform.isMusl { + NIX_LDFLAGS = "-lexecinfo"; + }; + + postPatch = '' + # this conditional gates the installation of share/gsettings-schemas/.../glib-2.0/schemas/gschemas.compiled. + substituteInPlace meson.build \ + --replace 'if not meson.is_cross_build()' 'if ${lib.boolToString compileSchemas}' + + files=( + build-aux/meson/gen-demo-header.py + demos/gtk-demo/geninclude.py + gdk/broadway/gen-c-array.py + gdk/gen-gdk-gresources-xml.py + gtk/gen-gtk-gresources-xml.py + gtk/gentypefuncs.py + ) + + chmod +x ''${files[@]} + patchShebangs ''${files[@]} + + ''; + + preInstall = '' + OLD_PATH="$PATH" + PATH="$PATH:$dev/bin" # so the install script finds gtk4-update-icon-cache + ''; + + postInstall = '' + PATH="$OLD_PATH" + '' + lib.optionalString (!stdenv.isDarwin) '' + # The updater is needed for nixos env and it's tiny. + moveToOutput bin/gtk4-update-icon-cache "$out" + # Launcher + moveToOutput bin/gtk-launch "$out" + + # TODO: patch glib directly + for f in $dev/bin/gtk4-encode-symbolic-svg; do + wrapProgram $f --prefix XDG_DATA_DIRS : "${shared-mime-info}/share" + done + '' + lib.optionalString broadwaySupport '' + # Broadway daemon + moveToOutput bin/gtk4-broadwayd "$out" + ''; + + # Wrap demos + postFixup = lib.optionalString (!stdenv.isDarwin) '' + demos=(gtk4-demo gtk4-demo-application gtk4-icon-browser gtk4-widget-factory) + + for program in ''${demos[@]}; do + wrapProgram $dev/bin/$program \ + --prefix XDG_DATA_DIRS : "$GSETTINGS_SCHEMAS_PATH:$out/share/gsettings-schemas/${pname}-${version}" + done + '' + lib.optionalString x11Support '' + # Cannot be in postInstall, otherwise _multioutDocs hook in preFixup will move right back. + moveToOutput "share/doc" "$devdoc" + ''; + + passthru = { + updateScript = gnome.updateScript { + packageName = "gtk"; + versionPolicy = "odd-unstable"; + attrPath = "gtk4"; + }; + }; + + meta = with lib; { + description = "A multi-platform toolkit for creating graphical user interfaces"; + longDescription = '' + GTK is a highly usable, feature rich toolkit for creating + graphical user interfaces which boasts cross platform + compatibility and an easy to use API. GTK it is written in C, + but has bindings to many other popular programming languages + such as C++, Python and C# among others. GTK is licensed + under the GNU LGPL 2.1 allowing development of both free and + proprietary software with GTK without any license fees or + royalties. + ''; + homepage = "https://www.gtk.org/"; + license = licenses.lgpl2Plus; + maintainers = teams.gnome.members ++ (with maintainers; [ raskin ]); + platforms = platforms.all; + changelog = "https://gitlab.gnome.org/GNOME/gtk/-/raw/${version}/NEWS"; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh b/nixpkgs/pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh new file mode 100644 index 000000000000..0868a4a39101 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh @@ -0,0 +1,15 @@ +# shellcheck shell=bash + +fixupOutputHooks+=(_gtkCleanImmodulesCache) + +# Clean comments that link to generator of the file +_gtkCleanImmodulesCache() { + # gtk_module_path is where the modules are installed + # https://gitlab.gnome.org/GNOME/gtk/-/blob/3.24.24/gtk/gtkmodules.c#L68 + # gtk_binary_version can be retrived with: + # pkg-config --variable=gtk_binary_version gtk+-3.0 + local f="${prefix:?}/lib/@gtk_module_path@/@gtk_binary_version@/immodules.cache" + if [ -f "$f" ]; then + sed 's|Created by .*bin/gtk-query-|Created by bin/gtk-query-|' -i "$f" + fi +} diff --git a/nixpkgs/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh b/nixpkgs/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh new file mode 100644 index 000000000000..f28a856c4f50 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh @@ -0,0 +1,19 @@ +# shellcheck shell=bash + +# Packages often run gtk-update-icon-cache to include their icons in themes’ icon cache. +# However, since each package is installed to its own prefix, the files will only collide. +dropIconThemeCache() { + if [[ -z "${dontDropIconThemeCache:-}" ]]; then + local icondir="${out:?}/share/icons" + if [[ -d "${icondir}" ]]; then + # App icons are supposed to go to hicolor theme, since it is a fallback theme as per [icon-theme-spec], but some might still choose to install stylized icons to other themes. + find "${icondir}" -name 'icon-theme.cache' -print0 \ + | while IFS= read -r -d '' file; do + echo "Removing ${file}" + rm -f "${file}" + done + fi + fi +} + +preFixupPhases="${preFixupPhases-} dropIconThemeCache" diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-darwin-x11.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-darwin-x11.patch new file mode 100644 index 000000000000..9725cfb84260 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-darwin-x11.patch @@ -0,0 +1,22 @@ +--- a/gdk/x11/gdkapplaunchcontext-x11.c ++++ b/gdk/x11/gdkapplaunchcontext-x11.c +@@ -26,7 +26,6 @@ + #include <unistd.h> + + #include <glib.h> +-#include <gio/gdesktopappinfo.h> + + #include "gdkx.h" + #include "gdkapplaunchcontext.h" +@@ -363,10 +362,7 @@ + else + workspace_str = NULL; + +- if (G_IS_DESKTOP_APP_INFO (info)) +- application_id = g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (info)); +- else +- application_id = NULL; ++ application_id = NULL; + + startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu", + g_get_prgname (), diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch new file mode 100644 index 000000000000..3b1c080abf08 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch @@ -0,0 +1,54 @@ +From 8b822ab0060acdf4217f589411fe71574cbb09c0 Mon Sep 17 00:00:00 2001 +From: Daniel Trebbien <dtrebbien@gmail.com> +Date: Fri, 3 Jul 2015 12:08:18 -0400 +Subject: [PATCH] quartz: Bug 557780 - Missing support for depth == 1 in + gdk_image_new_for_depth() + +When the gtk2 client of Freeciv is started, an assertion failure is seen +immediately and the client stops: +"Gdk:ERROR:gdkimage-quartz.c:325:_gdk_image_new_for_depth: assertion +failed: (depth == 24 || depth == 32)" + +In this case, _gdk_image_new_for_depth() is being called from +_gdk_quartz_image_copy_to_image(). The GdkImage passed to this function +is NULL so a new GdkImage is created. However, the depth of the passed +GdkDrawable is 1 and this is passed directly as the `depth' parameter to +_gdk_image_new_for_depth(), leading to the assertion failure. + +In _gdk_quartz_image_copy_to_image(), rather than directly pass the +GdkDrawable's depth to _gdk_image_new_for_depth(), if the depth is 1, +then create the new GdkImage with depth 24. The case where the depth is +1 is already handled in _gdk_quartz_image_copy_to_image(). + +This allows the Freeciv 2.5.0 gtk2 client to start and play a game. +--- + gdk/quartz/gdkimage-quartz.c | 13 +++++++++---- + 1 file changed, 9 insertions(+), 4 deletions(-) + +diff --git a/gdk/quartz/gdkimage-quartz.c b/gdk/quartz/gdkimage-quartz.c +index 493efba..853ef61 100644 +--- a/gdk/quartz/gdkimage-quartz.c ++++ b/gdk/quartz/gdkimage-quartz.c +@@ -43,10 +43,15 @@ _gdk_quartz_image_copy_to_image (GdkDrawable *drawable, + + screen = gdk_drawable_get_screen (drawable); + if (!image) +- image = _gdk_image_new_for_depth (screen, GDK_IMAGE_FASTEST, NULL, +- width, height, +- gdk_drawable_get_depth (drawable)); +- ++ { ++ gint drawable_depth = gdk_drawable_get_depth (drawable); ++ if (drawable_depth == 1) ++ drawable_depth = 24; ++ image = _gdk_image_new_for_depth (screen, GDK_IMAGE_FASTEST, NULL, ++ width, height, ++ drawable_depth); ++ } ++ + if (GDK_IS_PIXMAP_IMPL_QUARTZ (drawable)) + { + GdkPixmapImplQuartz *pix_impl; +-- +2.3.2 (Apple Git-55) + diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-immodules.cache.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-immodules.cache.patch new file mode 100644 index 000000000000..1b8231756e71 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/2.0-immodules.cache.patch @@ -0,0 +1,27 @@ +--- a/gtk/gtkrc.c 2014-09-30 05:02:17.000000000 +0900 ++++ b/gtk/gtkrc.c 2016-04-09 17:39:51.363288355 +0900 +@@ -445,5 +445,23 @@ + if (var) + result = g_strdup (var); + ++ // check NIX_PROFILES paths. ++ const gchar *nixProfilesEnv = g_getenv ("NIX_PROFILES"); ++ gchar *cachePath; ++ guint i; ++ ++ if(nixProfilesEnv && !result){ ++ gchar **paths = g_strsplit(nixProfilesEnv, " ", -1); ++ for (i = 0; paths[i] != NULL; i++){ ++ cachePath = g_build_filename(paths[i], "etc", "gtk-2.0", "immodules.cache", NULL); ++ if( g_file_test( cachePath, G_FILE_TEST_EXISTS) ){ ++ if(result) g_free(result); ++ result = g_strdup(cachePath); ++ } ++ g_free(cachePath); ++ } ++ g_strfreev(paths); ++ } ++ + if (!result) + { + diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch new file mode 100644 index 000000000000..247dd3ea8456 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch @@ -0,0 +1,34 @@ +From 269f2d80ea41cde17612600841fbdc32e99010f5 Mon Sep 17 00:00:00 2001 +From: Giuseppe Bilotta <giuseppe.bilotta@gmail.com> +Date: Tue, 24 Jan 2017 12:30:08 +0100 +Subject: [PATCH] Xft setting fallback: compute DPI properly + +This is a partial revert of bdf0820c501437a2150d8ff0d5340246e713f73f. If +the Xft DPI settings are not explicitly set, use the values provided by +the X server rather than hard-coding the fallback value of 96. + +While an auto-configured Xorg already reports 96, this value can be +overriden by the user, and we should respect the user choice in this +case. There is no need to require them to set the same value in +different places (the Xorg DPI settings and Xft.dpi). +--- + gdk/x11/gdkxftdefaults.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/gdk/x11/gdkxftdefaults.c b/gdk/x11/gdkxftdefaults.c +index fa1cfde2ec..c462b78c4b 100644 +--- a/gdk/x11/gdkxftdefaults.c ++++ b/gdk/x11/gdkxftdefaults.c +@@ -174,7 +174,8 @@ init_xft_settings (GdkScreen *screen) + x11_screen->xft_rgba = FC_RGBA_UNKNOWN; + + if (!get_double_default (xdisplay, "dpi", &dpi_double)) +- dpi_double = 96.0; ++ dpi_double = (DisplayHeight(xdisplay, x11_screen->screen_num)*25.4)/ ++ DisplayHeightMM(xdisplay, x11_screen->screen_num); + + x11_screen->xft_dpi = (int)(0.5 + PANGO_SCALE * dpi_double); + } +-- +2.11.0.616.gd72966cf44.dirty + diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-darwin-x11.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-darwin-x11.patch new file mode 100644 index 000000000000..86631634b5bd --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-darwin-x11.patch @@ -0,0 +1,28 @@ +--- a/gdk/x11/gdkapplaunchcontext-x11.c ++++ b/gdk/x11/gdkapplaunchcontext-x11.c +@@ -27,7 +27,9 @@ + #include "gdkprivate-x11.h" + + #include <glib.h> ++#if defined(HAVE_GIO_UNIX) && !defined(__APPLE__) + #include <gio/gdesktopappinfo.h> ++#endif + + #include <string.h> + #include <unistd.h> +@@ -352,10 +354,15 @@ + else + workspace_str = NULL; + ++#if defined(HAVE_GIO_UNIX) && !defined(__APPLE__) + if (G_IS_DESKTOP_APP_INFO (info)) + application_id = g_desktop_app_info_get_filename (G_DESKTOP_APP_INFO (info)); + else + application_id = NULL; ++#else ++ application_id = NULL; ++#warning Please add support for creating AppInfo from id for your OS ++#endif + + startup_id = g_strdup_printf ("%s-%lu-%s-%s-%d_TIME%lu", + g_get_prgname (), diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-immodules.cache.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-immodules.cache.patch new file mode 100644 index 000000000000..bbe5f28dbd3e --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/3.0-immodules.cache.patch @@ -0,0 +1,27 @@ +--- a/gtk/deprecated/gtkrc.c 2016-04-02 18:43:08.401663112 +0900 ++++ b/gtk/deprecated/gtkrc.c 2016-04-02 18:29:19.927608592 +0900 +@@ -774,5 +774,23 @@ + if (var) + result = g_strdup (var); + ++ // check NIX_PROFILES paths. ++ const gchar *nixProfilesEnv = g_getenv ("NIX_PROFILES"); ++ gchar *cachePath; ++ guint i; ++ ++ if(nixProfilesEnv && !result){ ++ gchar **paths = g_strsplit(nixProfilesEnv, " ", -1); ++ for (i = 0; paths[i] != NULL; i++){ ++ cachePath = g_build_filename(paths[i], "etc", "gtk-3.0", "immodules.cache", NULL); ++ if( g_file_test( cachePath, G_FILE_TEST_EXISTS) ){ ++ if(result) g_free(result); ++ result = g_strdup(cachePath); ++ } ++ g_free(cachePath); ++ } ++ g_strfreev(paths); ++ } ++ + if (!result) + { + diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/4.0-fix-darwin-build.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/4.0-fix-darwin-build.patch new file mode 100644 index 000000000000..01f4377aa0a7 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/4.0-fix-darwin-build.patch @@ -0,0 +1,31 @@ +diff --git a/gdk/macos/gdkmacospasteboard-private.h b/gdk/macos/gdkmacospasteboard-private.h +index fdeb936..c4b8666 100644 +--- a/gdk/macos/gdkmacospasteboard-private.h ++++ b/gdk/macos/gdkmacospasteboard-private.h +@@ -27,6 +27,10 @@ + + G_BEGIN_DECLS + ++#ifndef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER ++typedef NSString *NSPasteboardType; ++#endif ++ + @interface GdkMacosPasteboardItemDataProvider : NSObject <NSPasteboardItemDataProvider> + { + GdkContentProvider *_contentProvider; +diff --git a/gdk/macos/gdkmacospasteboard.c b/gdk/macos/gdkmacospasteboard.c +index 66b3c9f..b9e0d8a 100644 +--- a/gdk/macos/gdkmacospasteboard.c ++++ b/gdk/macos/gdkmacospasteboard.c +@@ -400,7 +400,11 @@ _gdk_macos_pasteboard_register_drag_types (NSWindow *window) + gdk_content_formats_get_gtypes (formats, &n_gtypes); + + if (n_gtypes) ++#ifdef AVAILABLE_MAC_OS_X_VERSION_10_13_AND_LATER + [ret addObject:NSPasteboardTypeURL]; ++#else ++ [ret addObject:[[NSString alloc] initWithUTF8String:"public.url"]]; ++#endif + + gdk_content_formats_unref (formats); + } diff --git a/nixpkgs/pkgs/development/libraries/gtk/patches/gtk2-theme-paths.patch b/nixpkgs/pkgs/development/libraries/gtk/patches/gtk2-theme-paths.patch new file mode 100644 index 000000000000..edd69b078076 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/gtk/patches/gtk2-theme-paths.patch @@ -0,0 +1,40 @@ +Subject: [PATCHv2] gtk: Patch GTK+ to look for themes in profiles. +To: guix-devel@gnu.org +Date: Sun, 13 Mar 2016 15:17:37 +1100 +Url: https://lists.gnu.org/archive/html/guix-devel/2016-03/msg00492.html + +diff -Naur gtk+-2.24.28.new/gtk/gtkrc.c gtk+-2.24.28/gtk/gtkrc.c +--- gtk+-2.24.28.new/gtk/gtkrc.c 2016-03-13 10:31:14.413644362 +1100 ++++ gtk+-2.24.28/gtk/gtkrc.c 2016-03-13 12:51:34.723398423 +1100 +@@ -808,6 +808,8 @@ + gchar *path = NULL; + const gchar *home_dir; + gchar *subpath; ++ const gchar * const *xdg_data_dirs; ++ gint i; + + if (type) + subpath = g_strconcat ("gtk-2.0-", type, +@@ -830,6 +832,22 @@ + } + + if (!path) ++ { ++ xdg_data_dirs = g_get_system_data_dirs (); ++ for (i = 0; xdg_data_dirs[i]; i++) ++ { ++ path = g_build_filename (xdg_data_dirs[i], "themes", name, subpath, NULL); ++ if (g_file_test (path, G_FILE_TEST_EXISTS)) ++ break; ++ else ++ { ++ g_free (path); ++ path = NULL; ++ } ++ } ++ } ++ ++ if (!path) + { + gchar *theme_dir = gtk_rc_get_theme_dir (); + path = g_build_filename (theme_dir, name, subpath, NULL); |