about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/data/icons/hicolor-icon-theme/setup-hook.sh16
-rw-r--r--pkgs/development/libraries/gtk/gtk3-setup-hook.sh21
2 files changed, 24 insertions, 13 deletions
diff --git a/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh b/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
index 29306cb316af..f07bab4b269f 100644
--- a/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
+++ b/pkgs/data/icons/hicolor-icon-theme/setup-hook.sh
@@ -1,21 +1,13 @@
+# shellcheck shell=bash
+
 # Populate XDG_ICON_DIRS
 hicolorIconThemeHook() {
 
     # where to find icon themes
     if [ -d "$1/share/icons" ]; then
-      addToSearchPath XDG_ICON_DIRS $1/share
+      addToSearchPath XDG_ICON_DIRS "$1/share"
     fi
-	
 }
 
 # I think this is meant to be a runtime dep
-addEnvHooks "$hostOffset" hicolorIconThemeHook
-
-# Remove icon cache
-hicolorPreFixupPhase() {
-    rm -f $out/share/icons/hicolor/icon-theme.cache
-    rm -f $out/share/icons/HighContrast/icon-theme.cache
-}
-
-preFixupPhases="$preFixupPhases hicolorPreFixupPhase"
-
+addEnvHooks "${hostOffset:?}" hicolorIconThemeHook
diff --git a/pkgs/development/libraries/gtk/gtk3-setup-hook.sh b/pkgs/development/libraries/gtk/gtk3-setup-hook.sh
index bddeb2d25d50..5a0eea0fc285 100644
--- a/pkgs/development/libraries/gtk/gtk3-setup-hook.sh
+++ b/pkgs/development/libraries/gtk/gtk3-setup-hook.sh
@@ -1,10 +1,29 @@
+# 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"
+    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
 }
 
+# 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"