about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/gtk/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/gtk/hooks')
-rw-r--r--nixpkgs/pkgs/development/libraries/gtk/hooks/drop-icon-theme-cache.sh19
-rw-r--r--nixpkgs/pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh12
-rw-r--r--nixpkgs/pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh11
-rw-r--r--nixpkgs/pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh11
4 files changed, 53 insertions, 0 deletions
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/hooks/gtk2-clean-immodules-cache.sh b/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh
new file mode 100644
index 000000000000..dde991fd27cd
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk2-clean-immodules-cache.sh
@@ -0,0 +1,12 @@
+# 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/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh b/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh
new file mode 100644
index 000000000000..d2d5287831a0
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk3-clean-immodules-cache.sh
@@ -0,0 +1,11 @@
+# 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/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh b/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh
new file mode 100644
index 000000000000..49f7051aabb6
--- /dev/null
+++ b/nixpkgs/pkgs/development/libraries/gtk/hooks/gtk4-clean-immodules-cache.sh
@@ -0,0 +1,11 @@
+# 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
+}