gtk: use one clean-immodules-cache setup-hook

Use one hook with substituteAll instead
of duplicating the hook for every version.
This commit is contained in:
WORLDofPEACE 2021-02-21 07:43:13 -05:00 committed by github-actions[bot]
parent e3d3643f1b
commit 45bdf88043
7 changed files with 53 additions and 39 deletions

View file

@ -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 ];

View file

@ -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 {

View file

@ -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 {

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}

View file

@ -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
}