Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)

desktopToDarwinBundle: fix 16x, 32x app icons

Changes the script to produce rgb+mask images for 16x and 32x icons
instead of png.

Using icns files containing 16x and 32x png images for app bundles
results in Finder misrendering icons for these sizes (even though the
icns files are rendered correctly when viewed by themselves)

+18
+18
pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh
··· 92 93 echo "desktopToDarwinBundle: resizing icon $in to $out, size $dim" >&2 94 magick convert -scale "${dim}x${dim}" -density "$density" -units PixelsPerInch "$in" "$out" 95 } 96 97 function synthesizeIcon() { ··· 107 echo "desktopToDarwinBundle: rasterizing svg $in to $out, size $dim" >&2 108 rsvg-convert --keep-aspect-ratio --width "$dim" --height "$dim" "$in" --output "$out" 109 magick convert -density "$density" -units PixelsPerInch "$out" "$out" 110 else 111 return 1 112 fi 113 } 114 ··· 151 fixed) 152 local density=$((72 * scale))x$((72 * scale)) 153 magick convert -density "$density" -units PixelsPerInch "$icon" "$result" 154 foundIcon=OTHER 155 ;; 156 threshold)
··· 92 93 echo "desktopToDarwinBundle: resizing icon $in to $out, size $dim" >&2 94 magick convert -scale "${dim}x${dim}" -density "$density" -units PixelsPerInch "$in" "$out" 95 + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" 96 } 97 98 function synthesizeIcon() { ··· 108 echo "desktopToDarwinBundle: rasterizing svg $in to $out, size $dim" >&2 109 rsvg-convert --keep-aspect-ratio --width "$dim" --height "$dim" "$in" --output "$out" 110 magick convert -density "$density" -units PixelsPerInch "$out" "$out" 111 + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" 112 else 113 return 1 114 + fi 115 + } 116 + 117 + # macOS does not correctly display 16x and 32x png icons on app bundles 118 + # they need to be converted to rgb+mask (argb is supported only from macOS 11) 119 + function convertIfUnsupportedIcon() { 120 + local -r in=$1 121 + local -r iconSize=$2 122 + local -r scale=$3 123 + local -r out=${in%.png}.rgb 124 + 125 + if [[ ($scale -eq 1) && ($iconSize -eq 32 || $iconSize -eq 16) ]]; then 126 + echo "desktopToDarwinBundle: converting ${iconSize}x icon to rgb" >&2 127 + icnsutil convert "$out" "$in" 128 + rm "$in" 129 fi 130 } 131 ··· 168 fixed) 169 local density=$((72 * scale))x$((72 * scale)) 170 magick convert -density "$density" -units PixelsPerInch "$icon" "$result" 171 + convertIfUnsupportedIcon "$result" "$iconSize" "$scale" 172 foundIcon=OTHER 173 ;; 174 threshold)