2024-07-15 19:30:45 +00:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
fetchurl,
|
|
|
|
stdenvNoCC,
|
|
|
|
unzip,
|
|
|
|
ipsw,
|
|
|
|
_7zz,
|
|
|
|
}:
|
2023-12-20 07:13:37 +00:00
|
|
|
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
|
|
|
|
'';
|
|
|
|
|
2023-12-20 23:20:02 +00:00
|
|
|
passthru.font = true;
|
2023-12-20 07:13:37 +00:00
|
|
|
meta = with lib; {
|
|
|
|
license = licenses.unfree;
|
|
|
|
platforms = platforms.all;
|
2023-12-20 23:20:02 +00:00
|
|
|
maintainer = with maintainers; [ artemist ];
|
2023-12-20 07:13:37 +00:00
|
|
|
description = "${family} fonts as downloadable from macOS";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-07-15 19:30:45 +00:00
|
|
|
in
|
|
|
|
{
|
2023-12-20 07:13:37 +00:00
|
|
|
extra = lib.mapAttrs' mkExtraFont root.extra;
|
|
|
|
allExtra = (mkExtraFont "All Extra" root.all_extra).value;
|
2023-12-20 23:20:02 +00:00
|
|
|
|
2024-07-15 19:30:45 +00:00
|
|
|
base =
|
|
|
|
let
|
|
|
|
data = root.base;
|
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation {
|
|
|
|
pname = "macos-fonts-base";
|
|
|
|
version = with data; "${version}-${build}";
|
2023-12-20 23:20:02 +00:00
|
|
|
|
2024-07-15 19:30:45 +00:00
|
|
|
src = fetchurl { inherit (data) url hash; };
|
2023-12-20 23:20:02 +00:00
|
|
|
|
2024-07-15 19:30:45 +00:00
|
|
|
installPhase = ''
|
|
|
|
${ipsw}/bin/ipsw extract $src --dmg fs
|
|
|
|
${_7zz}/bin/7zz e -i'!4.apfs' ${data.build}*/*.dmg
|
2023-12-20 23:20:02 +00:00
|
|
|
|
2024-07-15 19:30:45 +00:00
|
|
|
mkdir -p $out/share/fonts/apple
|
2023-12-20 23:20:02 +00:00
|
|
|
|
2024-07-15 19:30:45 +00:00
|
|
|
# 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
|
|
|
|
'';
|
2023-12-20 23:20:02 +00:00
|
|
|
|
2024-07-15 19:30:45 +00:00
|
|
|
dontUnpack = true;
|
|
|
|
};
|
2023-12-20 07:13:37 +00:00
|
|
|
}
|