diff --git a/pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh b/pkgs/by-name/gt/gtk2/hooks/clean-immodules-cache.sh similarity index 100% rename from pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh rename to pkgs/by-name/gt/gtk2/hooks/clean-immodules-cache.sh diff --git a/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh b/pkgs/by-name/gt/gtk2/hooks/drop-icon-theme-cache.sh similarity index 100% rename from pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh rename to pkgs/by-name/gt/gtk2/hooks/drop-icon-theme-cache.sh diff --git a/pkgs/development/libraries/gtk/2.x.nix b/pkgs/by-name/gt/gtk2/package.nix similarity index 100% rename from pkgs/development/libraries/gtk/2.x.nix rename to pkgs/by-name/gt/gtk2/package.nix diff --git a/pkgs/development/libraries/gtk/patches/2.0-clang.patch b/pkgs/by-name/gt/gtk2/patches/2.0-clang.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/2.0-clang.patch rename to pkgs/by-name/gt/gtk2/patches/2.0-clang.patch diff --git a/pkgs/development/libraries/gtk/patches/2.0-darwin-x11.patch b/pkgs/by-name/gt/gtk2/patches/2.0-darwin-x11.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/2.0-darwin-x11.patch rename to pkgs/by-name/gt/gtk2/patches/2.0-darwin-x11.patch diff --git a/pkgs/development/libraries/gtk/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch b/pkgs/by-name/gt/gtk2/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch rename to pkgs/by-name/gt/gtk2/patches/2.0-gnome_bugzilla_557780_306776_freeciv_darwin.patch diff --git a/pkgs/development/libraries/gtk/patches/2.0-immodules.cache.patch b/pkgs/by-name/gt/gtk2/patches/2.0-immodules.cache.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/2.0-immodules.cache.patch rename to pkgs/by-name/gt/gtk2/patches/2.0-immodules.cache.patch diff --git a/pkgs/development/libraries/gtk/patches/gtk2-theme-paths.patch b/pkgs/by-name/gt/gtk2/patches/gtk2-theme-paths.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/gtk2-theme-paths.patch rename to pkgs/by-name/gt/gtk2/patches/gtk2-theme-paths.patch diff --git a/pkgs/by-name/gt/gtk3/hooks/clean-immodules-cache.sh b/pkgs/by-name/gt/gtk3/hooks/clean-immodules-cache.sh new file mode 100644 index 000000000000..0868a4a39101 --- /dev/null +++ b/pkgs/by-name/gt/gtk3/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/pkgs/by-name/gt/gtk3/hooks/drop-icon-theme-cache.sh b/pkgs/by-name/gt/gtk3/hooks/drop-icon-theme-cache.sh new file mode 100644 index 000000000000..0762285843eb --- /dev/null +++ b/pkgs/by-name/gt/gtk3/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 +} + +appendToVar preFixupPhases dropIconThemeCache diff --git a/pkgs/development/libraries/gtk/3.x.nix b/pkgs/by-name/gt/gtk3/package.nix similarity index 100% rename from pkgs/development/libraries/gtk/3.x.nix rename to pkgs/by-name/gt/gtk3/package.nix diff --git a/pkgs/development/libraries/gtk/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch b/pkgs/by-name/gt/gtk3/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch rename to pkgs/by-name/gt/gtk3/patches/3.0-Xft-setting-fallback-compute-DPI-properly.patch diff --git a/pkgs/development/libraries/gtk/patches/3.0-darwin-x11.patch b/pkgs/by-name/gt/gtk3/patches/3.0-darwin-x11.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/3.0-darwin-x11.patch rename to pkgs/by-name/gt/gtk3/patches/3.0-darwin-x11.patch diff --git a/pkgs/development/libraries/gtk/patches/3.0-immodules.cache.patch b/pkgs/by-name/gt/gtk3/patches/3.0-immodules.cache.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/3.0-immodules.cache.patch rename to pkgs/by-name/gt/gtk3/patches/3.0-immodules.cache.patch diff --git a/pkgs/development/libraries/gtk/patches/3.0-mr5531-backport.patch b/pkgs/by-name/gt/gtk3/patches/3.0-mr5531-backport.patch similarity index 100% rename from pkgs/development/libraries/gtk/patches/3.0-mr5531-backport.patch rename to pkgs/by-name/gt/gtk3/patches/3.0-mr5531-backport.patch diff --git a/pkgs/by-name/gt/gtk4/hooks/clean-immodules-cache.sh b/pkgs/by-name/gt/gtk4/hooks/clean-immodules-cache.sh new file mode 100644 index 000000000000..0868a4a39101 --- /dev/null +++ b/pkgs/by-name/gt/gtk4/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/pkgs/by-name/gt/gtk4/hooks/drop-icon-theme-cache.sh b/pkgs/by-name/gt/gtk4/hooks/drop-icon-theme-cache.sh new file mode 100644 index 000000000000..0762285843eb --- /dev/null +++ b/pkgs/by-name/gt/gtk4/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 +} + +appendToVar preFixupPhases dropIconThemeCache diff --git a/pkgs/development/libraries/gtk/4.x.nix b/pkgs/by-name/gt/gtk4/package.nix similarity index 100% rename from pkgs/development/libraries/gtk/4.x.nix rename to pkgs/by-name/gt/gtk4/package.nix diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 76546fd788fa..67d586801fac 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -6983,8 +6983,6 @@ with pkgs; pangomm_2_42 = callPackage ../development/libraries/pangomm/2.42.nix { }; - gtk2 = callPackage ../development/libraries/gtk/2.x.nix { }; - gtk2-x11 = gtk2.override { cairo = cairo.override { x11Support = true; }; pango = pango.override { @@ -6994,10 +6992,6 @@ with pkgs; gdktarget = "x11"; }; - gtk3 = callPackage ../development/libraries/gtk/3.x.nix { }; - - gtk4 = callPackage ../development/libraries/gtk/4.x.nix { }; - # On darwin gtk uses cocoa by default instead of x11. gtk3-x11 = gtk3.override { cairo = cairo.override { x11Support = true; };