fonts/apple/default.nix

73 lines
1.7 KiB
Nix
Raw Permalink Normal View History

2024-07-15 19:30:45 +00:00
{
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";
};
};
};
2024-07-15 19:30:45 +00:00
in
{
extra = lib.mapAttrs' mkExtraFont root.extra;
allExtra = (mkExtraFont "All Extra" root.all_extra).value;
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}";
2024-07-15 19:30:45 +00:00
src = fetchurl { inherit (data) url hash; };
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
2024-07-15 19:30:45 +00:00
mkdir -p $out/share/fonts/apple
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
'';
2024-07-15 19:30:45 +00:00
dontUnpack = true;
};
}