{ lib, fetchurl, stdenvNoCC, unzip, ipsw, _7zz, }: let root = lib.importJSON ./assets.json; mkExtraFont = family: data: { name = lib.replaceStrings [ " " ] [ "-" ] family; value = stdenvNoCC.mkDerivation { name = family; srcs = map fetchurl data.assets; dontUnpack = true; installPhase = '' mkdir -p $out/share/fonts/apple i=0 for src in $srcs; do mkdir $i ${unzip}/bin/unzip -d $i $src cp -v -t $out/share/fonts/apple $i/AssetData/*.{ttc,ttf,otf} i=$((i+1)) done ''; passthru.font = true; meta = with lib; { license = licenses.unfree; platforms = platforms.all; maintainer = with maintainers; [ artemist ]; description = "${family} fonts as downloadable from macOS"; }; }; }; in { extra = lib.mapAttrs' mkExtraFont root.extra; allExtra = (mkExtraFont "All Extra" root.all_extra).value; base = let data = root.base; in stdenvNoCC.mkDerivation { pname = "macos-fonts-base"; version = with data; "${version}-${build}"; src = fetchurl { inherit (data) url hash; }; installPhase = '' ${ipsw}/bin/ipsw extract $src --dmg fs ${_7zz}/bin/7zz e -i'!4.apfs' ${data.build}*/*.dmg mkdir -p $out/share/fonts/apple # This gives us some erros, ignore that # Skipping overwrite because Apple has duplicate fonts for some reason ${_7zz}/bin/7zz e -i'!System/Library/Fonts' \ -i'!System/Library/PrivateFrameworks/FontServices.framework/Versions/A/Resources/Fonts/ApplicationSupport' \ 4.apfs -aos -o$out/share/fonts/apple || true ''; dontUnpack = true; }; }