How to define derivations for macOS pkg archives in nix?

A number of apps for macOS are distributed as pkg archives rather than dmg.

There’s an undmg function and the unar function but unar is linux only atm. Furthermore, there’s no wrapper I can see for /usr/sbin/installer unless I’m mistaken.

Has anyone solved this for macOS with nix?

We have undmg to unpack dmg images and pkg archives can be extracted with some combination of xar, pbxz and cpio (take a look at the apple sdk for an example).

However package archives include an installer script to put these into place which won’t work in nix builds. This means you’ll have to manually do this as well as patch everything that assumes the location is global, like the install_name header of libraries.