From 059ac8281d2c088794b41db74072393ac2b0bae5 Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Fri, 22 Nov 2024 21:33:37 +0100 Subject: [PATCH 1/2] icnsutil: include pillow dependency pillow is neccessary for `icnsutil convert` to work --- pkgs/development/python-modules/icnsutil/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/development/python-modules/icnsutil/default.nix b/pkgs/development/python-modules/icnsutil/default.nix index 8061c62feb22..6952aa33397f 100644 --- a/pkgs/development/python-modules/icnsutil/default.nix +++ b/pkgs/development/python-modules/icnsutil/default.nix @@ -4,6 +4,7 @@ fetchFromGitHub, python, pythonOlder, + pillow, }: buildPythonPackage rec { @@ -20,6 +21,8 @@ buildPythonPackage rec { hash = "sha256-tiq8h6s2noWLBIOIWcj8jfSqJFN01ee2uoHN4aFwn7s="; }; + dependencies = [ pillow ]; + checkPhase = '' ${python.interpreter} tests/test_icnsutil.py ${python.interpreter} tests/test_cli.py From 3b52cd4c1bded09d5a4d9b2dc17ff1736ea89b3d Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Fri, 22 Nov 2024 21:34:28 +0100 Subject: [PATCH 2/2] 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) --- .../setup-hooks/desktop-to-darwin-bundle.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh b/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh index d7cab0e81a60..4fbef4baa512 100644 --- a/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh +++ b/pkgs/build-support/setup-hooks/desktop-to-darwin-bundle.sh @@ -92,6 +92,7 @@ convertIconTheme() { echo "desktopToDarwinBundle: resizing icon $in to $out, size $dim" >&2 magick convert -scale "${dim}x${dim}" -density "$density" -units PixelsPerInch "$in" "$out" + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" } function synthesizeIcon() { @@ -107,11 +108,27 @@ convertIconTheme() { echo "desktopToDarwinBundle: rasterizing svg $in to $out, size $dim" >&2 rsvg-convert --keep-aspect-ratio --width "$dim" --height "$dim" "$in" --output "$out" magick convert -density "$density" -units PixelsPerInch "$out" "$out" + convertIfUnsupportedIcon "$out" "$iconSize" "$scale" else return 1 fi } + # macOS does not correctly display 16x and 32x png icons on app bundles + # they need to be converted to rgb+mask (argb is supported only from macOS 11) + function convertIfUnsupportedIcon() { + local -r in=$1 + local -r iconSize=$2 + local -r scale=$3 + local -r out=${in%.png}.rgb + + if [[ ($scale -eq 1) && ($iconSize -eq 32 || $iconSize -eq 16) ]]; then + echo "desktopToDarwinBundle: converting ${iconSize}x icon to rgb" >&2 + icnsutil convert "$out" "$in" + rm "$in" + fi + } + function getIcons() { local -r sharePath=$1 local -r iconname=$2 @@ -151,6 +168,7 @@ convertIconTheme() { fixed) local density=$((72 * scale))x$((72 * scale)) magick convert -density "$density" -units PixelsPerInch "$icon" "$result" + convertIfUnsupportedIcon "$result" "$iconSize" "$scale" foundIcon=OTHER ;; threshold)