lol
1{ stdenv
2, lib
3, buildNpmPackage
4, fetchFromGitHub
5, darwin
6, remarshal
7, ttfautohint-nox
8 # Custom font set options.
9 # See https://typeof.net/Iosevka/customizer
10 # Can be a raw TOML string, or a Nix attrset.
11
12 # Ex:
13 # privateBuildPlan = ''
14 # [buildPlans.iosevka-custom]
15 # family = "Iosevka Custom"
16 # spacing = "normal"
17 # serifs = "sans"
18 #
19 # [buildPlans.iosevka-custom.variants.design]
20 # capital-j = "serifless"
21 #
22 # [buildPlans.iosevka-custom.variants.italic]
23 # i = "tailed"
24 # '';
25
26 # Or:
27 # privateBuildPlan = {
28 # family = "Iosevka Custom";
29 # spacing = "normal";
30 # serifs = "sans";
31 #
32 # variants = {
33 # design.capital-j = "serifless";
34 # italic.i = "tailed";
35 # };
36 # }
37, privateBuildPlan ? null
38 # Extra parameters. Can be used for ligature mapping.
39 # It must be a raw TOML string.
40
41 # Ex:
42 # extraParameters = ''
43 # [[iosevka.compLig]]
44 # unicode = 57808 # 0xe1d0
45 # featureTag = 'XHS0'
46 # sequence = "+>"
47 # '';
48, extraParameters ? null
49 # Custom font set name. Required if any custom settings above.
50, set ? null
51}:
52
53assert (privateBuildPlan != null) -> set != null;
54assert (extraParameters != null) -> set != null;
55
56buildNpmPackage rec {
57 pname = if set != null then "iosevka-${set}" else "iosevka";
58 version = "27.3.5";
59
60 src = fetchFromGitHub {
61 owner = "be5invis";
62 repo = "iosevka";
63 rev = "v${version}";
64 hash = "sha256-dqXr/MVOuEmAMueaRWsnzY9MabhnyBRtLR9IDVLN79I=";
65 };
66
67 npmDepsHash = "sha256-bux8aFBP1Pi5pAQY1jkNTqD2Ny2j+QQs+QRaXWJj6xg=";
68
69 nativeBuildInputs = [
70 remarshal
71 ttfautohint-nox
72 ] ++ lib.optionals stdenv.isDarwin [
73 # libtool
74 darwin.cctools
75 ];
76
77 buildPlan =
78 if builtins.isAttrs privateBuildPlan then
79 builtins.toJSON { buildPlans.${pname} = privateBuildPlan; }
80 else
81 privateBuildPlan;
82
83 inherit extraParameters;
84 passAsFile = [ "extraParameters" ] ++ lib.optionals
85 (
86 !(builtins.isString privateBuildPlan
87 && lib.hasPrefix builtins.storeDir privateBuildPlan)
88 ) [ "buildPlan" ];
89
90 configurePhase = ''
91 runHook preConfigure
92 ${lib.optionalString (builtins.isAttrs privateBuildPlan) ''
93 remarshal -i "$buildPlanPath" -o private-build-plans.toml -if json -of toml
94 ''}
95 ${lib.optionalString (builtins.isString privateBuildPlan
96 && (!lib.hasPrefix builtins.storeDir privateBuildPlan)) ''
97 cp "$buildPlanPath" private-build-plans.toml
98 ''}
99 ${lib.optionalString (builtins.isString privateBuildPlan
100 && (lib.hasPrefix builtins.storeDir privateBuildPlan)) ''
101 cp "$buildPlan" private-build-plans.toml
102 ''}
103 ${lib.optionalString (extraParameters != null) ''
104 echo -e "\n" >> params/parameters.toml
105 cat "$extraParametersPath" >> params/parameters.toml
106 ''}
107 runHook postConfigure
108 '';
109
110 buildPhase = ''
111 export HOME=$TMPDIR
112 runHook preBuild
113 npm run build --no-update-notifier -- --jCmd=$NIX_BUILD_CORES --verbose=9 ttf::$pname
114 runHook postBuild
115 '';
116
117 installPhase = ''
118 runHook preInstall
119 fontdir="$out/share/fonts/truetype"
120 install -d "$fontdir"
121 install "dist/$pname/ttf"/* "$fontdir"
122 runHook postInstall
123 '';
124
125 enableParallelBuilding = true;
126
127 meta = with lib; {
128 homepage = "https://typeof.net/Iosevka/";
129 downloadPage = "https://github.com/be5invis/Iosevka/releases";
130 description = "Versatile typeface for code, from code.";
131 longDescription = ''
132 Iosevka is an open-source, sans-serif + slab-serif, monospace +
133 quasi‑proportional typeface family, designed for writing code, using in
134 terminals, and preparing technical documents.
135 '';
136 license = licenses.ofl;
137 platforms = platforms.all;
138 maintainers = with maintainers; [
139 ttuegel
140 babariviere
141 rileyinman
142 AluisioASG
143 lunik1
144 ];
145 };
146}