From 45bdf88043a818f47ba8e256995c31e3b2f52524 Mon Sep 17 00:00:00 2001 From: WORLDofPEACE Date: Sun, 21 Feb 2021 07:43:13 -0500 Subject: [PATCH] gtk: use one clean-immodules-cache setup-hook Use one hook with substituteAll instead of duplicating the hook for every version. --- pkgs/development/libraries/gtk/2.x.nix | 14 ++++++++++++-- pkgs/development/libraries/gtk/3.x.nix | 16 ++++++++++++++-- pkgs/development/libraries/gtk/4.x.nix | 13 ++++++++++++- .../libraries/gtk/hooks/clean-immodules-cache.sh | 15 +++++++++++++++ .../gtk/hooks/gtk2-clean-immodules-cache.sh | 12 ------------ .../gtk/hooks/gtk3-clean-immodules-cache.sh | 11 ----------- .../gtk/hooks/gtk4-clean-immodules-cache.sh | 11 ----------- 7 files changed, 53 insertions(+), 39 deletions(-) create mode 100644 pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh delete mode 100644 pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh delete mode 100644 pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh delete mode 100644 pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh diff --git a/pkgs/development/libraries/gtk/2.x.nix b/pkgs/development/libraries/gtk/2.x.nix index 4304cb388d1..8f50c922f51 100644 --- a/pkgs/development/libraries/gtk/2.x.nix +++ b/pkgs/development/libraries/gtk/2.x.nix @@ -1,4 +1,4 @@ -{ config, lib, stdenv, fetchurl, pkg-config, gettext, glib, atk, pango, cairo, perl, xorg +{ config, lib, substituteAll, stdenv, fetchurl, pkg-config, gettext, glib, atk, pango, cairo, perl, xorg , gdk-pixbuf, xlibsWrapper, gobject-introspection , xineramaSupport ? stdenv.isLinux , cupsSupport ? config.gtk2.cups or stdenv.isLinux, cups ? null @@ -12,6 +12,16 @@ assert cupsSupport -> cups != null; with lib; +let + + gtkCleanImmodulesCache = substituteAll { + src = ./hooks/clean-immodules-cache.sh; + gtk_module_path = "gtk-2.0"; + gtk_binary_version = "2.10.0"; + }; + +in + stdenv.mkDerivation rec { pname = "gtk+"; version = "2.24.32"; @@ -27,8 +37,8 @@ stdenv.mkDerivation rec { enableParallelBuilding = true; setupHooks = [ - ./hooks/gtk2-clean-immodules-cache.sh ./hooks/drop-icon-theme-cache.sh + gtkCleanImmodulesCache ]; nativeBuildInputs = setupHooks ++ [ perl pkg-config gettext gobject-introspection ]; diff --git a/pkgs/development/libraries/gtk/3.x.nix b/pkgs/development/libraries/gtk/3.x.nix index 159b03a26e1..f9d739a43ea 100644 --- a/pkgs/development/libraries/gtk/3.x.nix +++ b/pkgs/development/libraries/gtk/3.x.nix @@ -1,4 +1,6 @@ -{ lib, stdenv +{ lib +, stdenv +, substituteAll , fetchurl , fetchpatch , pkg-config @@ -48,6 +50,16 @@ assert cupsSupport -> cups != null; +let + + gtkCleanImmodulesCache = substituteAll { + src = ./hooks/clean-immodules-cache.sh; + gtk_module_path = "gtk-3.0"; + gtk_binary_version = "3.0.0"; + }; + +in + stdenv.mkDerivation rec { pname = "gtk+3"; version = "3.24.24"; @@ -56,8 +68,8 @@ stdenv.mkDerivation rec { outputBin = "dev"; setupHooks = [ - ./hooks/gtk3-clean-immodules-cache.sh ./hooks/drop-icon-theme-cache.sh + gtkCleanImmodulesCache ]; src = fetchurl { diff --git a/pkgs/development/libraries/gtk/4.x.nix b/pkgs/development/libraries/gtk/4.x.nix index b05e9ea0393..28247d6c972 100644 --- a/pkgs/development/libraries/gtk/4.x.nix +++ b/pkgs/development/libraries/gtk/4.x.nix @@ -1,5 +1,6 @@ { lib , stdenv +, substituteAll , fetchurl , pkg-config , gettext @@ -53,6 +54,16 @@ assert cupsSupport -> cups != null; +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.0.3"; @@ -61,8 +72,8 @@ stdenv.mkDerivation rec { outputBin = "dev"; setupHooks = [ - ./hooks/gtk4-clean-immodules-cache.sh ./hooks/drop-icon-theme-cache.sh + gtkCleanImmodulesCache ]; src = fetchurl { diff --git a/pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh b/pkgs/development/libraries/gtk/hooks/clean-immodules-cache.sh new file mode 100644 index 00000000000..0868a4a3910 --- /dev/null +++ b/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/pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh b/pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh deleted file mode 100644 index dde991fd27c..00000000000 --- a/pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh +++ /dev/null @@ -1,12 +0,0 @@ -# shellcheck shell=bash - -fixupOutputHooks+=(_gtk2CleanComments) - -# Clean comments that link to generator of the file -_gtk2CleanComments() { - local f="${prefix:?}/lib/gtk-2.0/2.10.0/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/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh b/pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh deleted file mode 100644 index d2d5287831a..00000000000 --- a/pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh +++ /dev/null @@ -1,11 +0,0 @@ -# shellcheck shell=bash - -fixupOutputHooks+=(_gtk3CleanComments) - -# Clean comments that link to generator of the file -_gtk3CleanComments() { - local f="${prefix:?}/lib/gtk-3.0/3.0.0/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/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh b/pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh deleted file mode 100644 index 49f7051aabb..00000000000 --- a/pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh +++ /dev/null @@ -1,11 +0,0 @@ -# shellcheck shell=bash - -fixupOutputHooks+=(_gtk4CleanComments) - -# Clean comments that link to generator of the file -_gtk4CleanComments() { - local f="${prefix:?}/lib/gtk-4.0/4.0.0/immodules.cache" - if [ -f "$f" ]; then - sed 's|Created by .*bin/gtk-query-|Created by bin/gtk-query-|' -i "$f" - fi -}