1 { writeScriptBin, lib, makeBinaryWrapper }:
4 pListText = lib.generators.toPlist { } {
5 CFBundleDevelopmentRegion = "English";
6 CFBundleExecutable = "$name";
7 CFBundleIconFile = "$icon";
8 CFBundleIconFiles = [ "$icon" ];
9 CFBundleIdentifier = "org.nixos.$name";
10 CFBundleInfoDictionaryVersion = "6.0";
11 CFBundleName = "$name";
12 CFBundlePackageType = "APPL";
13 CFBundleSignature = "???";
15 in writeScriptBin "write-darwin-bundle" ''
20 # TODO: support executables with spaces in their names
21 readonly execName=''${3%% *} # Before the first space
22 [[ $3 =~ " " ]] && readonly execArgs=''${3#* } # Everything after the first space
24 readonly squircle=''${5:-1}
25 readonly plist=$prefix/Applications/$name.app/Contents/Info.plist
26 readonly binary=$prefix/bin/$execName
27 readonly bundleExecutable=$prefix/Applications/$name.app/Contents/MacOS/$name
33 if [[ $squircle == 0 || $squircle == "false" ]]; then
34 sed '/CFBundleIconFiles/,\|</array>|d' -i "$plist"
37 if [[ -n "$execArgs" ]]; then
39 source ${makeBinaryWrapper}/nix-support/setup-hook
40 # WORKAROUND: makeBinaryWrapper fails when -u is set
42 makeBinaryWrapper "$binary" "$bundleExecutable" --add-flags "$execArgs"
45 ln -s "$binary" "$bundleExecutable"