summary refs log tree commit diff
path: root/pkgs/development/libraries/gtk/drop-icon-theme-cache.sh
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/libraries/gtk/drop-icon-theme-cache.sh')
-rw-r--r--pkgs/development/libraries/gtk/drop-icon-theme-cache.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/pkgs/development/libraries/gtk/drop-icon-theme-cache.sh b/pkgs/development/libraries/gtk/drop-icon-theme-cache.sh
new file mode 100644
index 00000000000..8f2cb8a334a
--- /dev/null
+++ b/pkgs/development/libraries/gtk/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"