forgejo-lts: 7.0.10 -> 7.0.11
[NixPkgs.git] / pkgs / build-support / make-darwin-bundle / default.nix
bloba80ebf8fac9e6f030b8226dc2d3787219cff7980
1 # given a package with an executable and an icon, make a darwin bundle for
2 # it. This package should be used when generating launchers for native Darwin
3 # applications. If the package conatins a .desktop file use
4 # `desktopToDarwinLauncher` instead.
6 { lib, writeShellScript, writeDarwinBundle }:
8 { name # The name of the Application file.
9 , exec # Executable file.
10 , icon ? "" # Optional icon file.
13 writeShellScript "make-darwin-bundle-${name}" (''
14   function makeDarwinBundlePhase() {
15     mkdir -p "''${!outputBin}/Applications/${name}.app/Contents/MacOS"
16     mkdir -p "''${!outputBin}/Applications/${name}.app/Contents/Resources"
18     if [ -n "${icon}" ]; then
19       ln -s "${icon}" "''${!outputBin}/Applications/${name}.app/Contents/Resources"
20     fi
22     ${writeDarwinBundle}/bin/write-darwin-bundle "''${!outputBin}" "${name}" "${exec}"
23   }
25   appendToVar preDistPhases makeDarwinBundlePhase
26 '')