From 7a40437bddfaedeb4d0300afbc1bb2cbf9081290 Mon Sep 17 00:00:00 2001 From: toonn Date: Mon, 21 Mar 2022 12:35:42 +0100 Subject: [PATCH] write-darwin-bundle: Invert squircle logic Older macOS cannot interpret the `CFBundleIconFiles` key so we cannot rewrite the `CFBundleIconFile` entry without special consideration. I opted to fix this by inverting the squircle logic. We always add both the `CFBundleIconFile` and `CFBundleIconFiles` keys. The former is necessary for at least macOS 10.13 and probably 10.12. The latter seems to be ignored on those versions and overrides the former on newer versions of macOS. Inverting the logic also allows us to rely on the `toPlist` generator to generate the XML syntax, which is a nice bonus. --- .../make-darwin-bundle/write-darwin-bundle.nix | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix b/pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix index d21e0475e2df..fde977c3636b 100644 --- a/pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix +++ b/pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix @@ -5,6 +5,7 @@ let CFBundleDevelopmentRegion = "English"; CFBundleExecutable = "$name"; CFBundleIconFile = "$icon"; + CFBundleIconFiles = [ "$icon" ]; CFBundleIdentifier = "org.nixos.$name"; CFBundleInfoDictionaryVersion = "6.0"; CFBundleName = "$name"; @@ -25,11 +26,8 @@ in writeScriptBin "write-darwin-bundle" '' ${pListText} EOF - if [[ $squircle != 0 && $squircle != "false" ]]; then - sed " - s|CFBundleIconFile|CFBundleIconFiles|; - s|$icon|$icon| - " -i "$plist" + if [[ $squircle == 0 || $squircle == "false" ]]; then + sed '/CFBundleIconFiles/,\||d' -i "$plist" fi cat > "$prefix/Applications/$name.app/Contents/MacOS/$name" <