Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 140 lines 3.5 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 fetchurl, 5 unzip, 6}: 7 8let 9 makeSuperOTC = 10 { 11 family, 12 description, 13 rev, 14 hash, 15 zip ? "", 16 prefix ? "", 17 }: 18 let 19 Family = lib.toUpper (lib.substring 0 1 family) + lib.substring 1 (lib.stringLength family) family; 20 in 21 stdenvNoCC.mkDerivation rec { 22 pname = "source-han-${family}"; 23 version = lib.removeSuffix "R" rev; 24 25 src = fetchurl { 26 url = "https://github.com/adobe-fonts/source-han-${family}/releases/download/${rev}/${prefix}SourceHan${Family}.ttc${zip}"; 27 inherit hash; 28 }; 29 30 nativeBuildInputs = lib.optionals (zip == ".zip") [ unzip ]; 31 32 unpackPhase = 33 lib.optionalString (zip == "") '' 34 cp $src SourceHan${Family}.ttc${zip} 35 '' 36 + lib.optionalString (zip == ".zip") '' 37 unzip $src 38 ''; 39 40 installPhase = '' 41 runHook preInstall 42 43 install -Dm444 *.ttc -t $out/share/fonts/opentype/${pname} 44 45 runHook postInstall 46 ''; 47 48 meta = { 49 description = "Open source Pan-CJK ${description} typeface"; 50 homepage = "https://github.com/adobe-fonts/source-han-${family}"; 51 license = lib.licenses.ofl; 52 maintainers = with lib.maintainers; [ 53 taku0 54 emily 55 ]; 56 }; 57 }; 58 59 makeVariable = 60 { 61 family, 62 version, 63 hash, 64 format, 65 }: 66 let 67 Family = lib.toUpper (lib.substring 0 1 family) + lib.substring 1 (lib.stringLength family) family; 68 in 69 fetchurl { 70 pname = "source-han-${family}-vf-${format}"; 71 inherit version hash; 72 url = "https://raw.githubusercontent.com/adobe-fonts/source-han-${family}/${version}R/Variable/OTC/SourceHan${Family}-VF.${format}.ttc"; 73 recursiveHash = true; 74 downloadToTemp = true; 75 postFetch = "install -Dm444 $downloadedFile $out/share/fonts/variable/SourceHan${Family}-VF.${format}.ttc"; 76 77 meta = { 78 description = "Open source Pan-CJK ${Family} typeface"; 79 homepage = "https://github.com/adobe-fonts/source-han-${family}"; 80 license = lib.licenses.ofl; 81 maintainers = with lib.maintainers; [ 82 taku0 83 emily 84 ]; 85 }; 86 }; 87in 88{ 89 sans = makeSuperOTC { 90 family = "sans"; 91 description = "sans-serif"; 92 rev = "2.004R"; 93 hash = "sha256-b1kRiprdpaf+Tp5rtTgwn34dPFQR+anTKvMqeVAbfk8="; 94 zip = ".zip"; 95 }; 96 97 serif = makeSuperOTC { 98 family = "serif"; 99 description = "serif"; 100 rev = "2.003R"; 101 hash = "sha256-buaJq1eJSuNa9gSnPpXDcr2gMGYQ/6F5pHCOjNR6eV8="; 102 zip = ".zip"; 103 prefix = "01_"; 104 }; 105 106 mono = makeSuperOTC { 107 family = "mono"; 108 description = "monospaced"; 109 rev = "1.002"; 110 hash = "sha256-DBkkSN6QhI8R64M2h2iDqaNtxluJZeSJYAz8x6ZzWME="; 111 }; 112 113 sans-vf-otf = makeVariable { 114 family = "sans"; 115 version = "2.004"; 116 hash = "sha256-V7PE09c7h4RDS8Ij4PSI36Gy+LM+PVDi73Rcs+4DfHo="; 117 format = "otf"; 118 }; 119 120 sans-vf-ttf = makeVariable { 121 family = "sans"; 122 version = "2.004"; 123 hash = "sha256-mXTG/d30gUxzxkJpaH4vOawRXMSxxTXlHCvHEsfGqbc="; 124 format = "ttf"; 125 }; 126 127 serif-vf-otf = makeVariable { 128 family = "serif"; 129 version = "2.003"; 130 hash = "sha256-a6295Ukha9QY5ByMr2FUy13j5gZ1itnezvfJWmJjqt0="; 131 format = "otf"; 132 }; 133 134 serif-vf-ttf = makeVariable { 135 family = "serif"; 136 version = "2.003"; 137 hash = "sha256-F+FUQunfyAEBVV10lZxC3dzGTWhHgHzpTO8CjC3n4WY="; 138 format = "ttf"; 139 }; 140}