about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2022-03-21 12:35:42 +0100
committertoonn <toonn@toonn.io>2022-03-21 14:20:03 +0100
commit7a40437bddfaedeb4d0300afbc1bb2cbf9081290 (patch)
treea4e88529bf692f00b9204d5675961a45d3f603e5 /pkgs/build-support
parente5e8e1d9263031e98e4e7c3ab73c409b2d5f82d1 (diff)
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.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r--pkgs/build-support/make-darwin-bundle/write-darwin-bundle.nix8
1 files 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 d21e0475e2df5..fde977c3636b7 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|<string>$icon</string>|<array><string>$icon</string></array>|
-    " -i "$plist"
+  if [[ $squircle == 0 || $squircle == "false" ]]; then
+    sed  '/CFBundleIconFiles/,\|</array>|d' -i "$plist"
   fi
 
     cat > "$prefix/Applications/$name.app/Contents/MacOS/$name" <<EOF