nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, stdenvNoCC
3, fetchurl
4, unzip
5}:
6
7let
8 makePackage =
9 { family
10 , description
11 , rev
12 , hash
13 , zip ? ""
14 }:
15 let Family =
16 lib.toUpper (lib.substring 0 1 family) +
17 lib.substring 1 (lib.stringLength family) family;
18 in
19 stdenvNoCC.mkDerivation rec {
20 pname = "source-han-${family}";
21 version = lib.removeSuffix "R" rev;
22
23 src = fetchurl {
24 url = "https://github.com/adobe-fonts/source-han-${family}/releases/download/${rev}/SourceHan${Family}.ttc${zip}";
25 inherit hash;
26 };
27
28 nativeBuildInputs = lib.optionals (zip == ".zip") [ unzip ];
29
30 unpackPhase = lib.optionalString (zip == "") ''
31 cp $src SourceHan${Family}.ttc${zip}
32 '' + lib.optionalString (zip == ".zip") ''
33 unzip $src
34 '';
35
36 installPhase = ''
37 runHook preInstall
38
39 install -Dm444 *.ttc -t $out/share/fonts/opentype/${pname}
40
41 runHook postInstall
42 '';
43
44 meta = {
45 description = "An open source Pan-CJK ${description} typeface";
46 homepage = "https://github.com/adobe-fonts/source-han-${family}";
47 license = lib.licenses.ofl;
48 maintainers = with lib.maintainers; [ taku0 emily ];
49 };
50 };
51in
52{
53 sans = makePackage {
54 family = "sans";
55 description = "sans-serif";
56 rev = "2.004R";
57 hash = "sha256-b1kRiprdpaf+Tp5rtTgwn34dPFQR+anTKvMqeVAbfk8=";
58 zip = ".zip";
59 };
60
61 serif = makePackage {
62 family = "serif";
63 description = "serif";
64 rev = "2.000R";
65 hash = "sha256-RDgywab7gwT+YBO7F1KJvKOv0E/3+7Zi/pQl+UDsGcM=";
66 zip = ".zip";
67 };
68
69 mono = makePackage {
70 family = "mono";
71 description = "monospaced";
72 rev = "1.002";
73 hash = "sha256-DBkkSN6QhI8R64M2h2iDqaNtxluJZeSJYAz8x6ZzWME=";
74 };
75}