tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixos: let fontconfig default fonts be lists of fonts
Thomas Tuegel
11 years ago
9707ffd9
57ba2093
+35
-86
1 changed file
expand all
collapse all
unified
split
nixos
modules
config
fonts
fontconfig.nix
+35
-86
nixos/modules/config/fonts/fontconfig.nix
···
38
38
39
39
defaultFonts = {
40
40
monospace = mkOption {
41
41
-
type = types.str;
42
42
-
default = "DejaVu Sans Mono";
41
41
+
type = types.listOf types.str;
42
42
+
default = ["DejaVu Sans Mono"];
43
43
description = ''
44
44
-
System-wide default monospace font. The default is not set if the
45
45
-
option is set to <literal>""</literal>.
44
44
+
System-wide default monospace font(s). Multiple fonts may be
45
45
+
listed in case multiple languages must be supported.
46
46
'';
47
47
};
48
48
49
49
sansSerif = mkOption {
50
50
-
type = types.str;
51
51
-
default = "DejaVu Sans";
50
50
+
type = types.listOf types.str;
51
51
+
default = ["DejaVu Sans"];
52
52
description = ''
53
53
-
System-wide default sans serif font. The default is not set if the
54
54
-
option is set to <literal>""</literal>.
53
53
+
System-wide default sans serif font(s). Multiple fonts may be
54
54
+
listed in case multiple languages must be supported.
55
55
'';
56
56
};
57
57
58
58
serif = mkOption {
59
59
-
type = types.str;
60
60
-
default = "DejaVu Serif";
59
59
+
type = types.listOf types.str;
60
60
+
default = ["DejaVu Serif"];
61
61
description = ''
62
62
-
System-wide default serif font. The default is not set if the
63
63
-
option is set to <literal>""</literal>.
62
62
+
System-wide default serif font(s). Multiple fonts may be listed
63
63
+
in case multiple languages must be supported.
64
64
'';
65
65
};
66
66
};
···
142
142
config =
143
143
let fontconfig = config.fonts.fontconfig;
144
144
fcBool = x: "<bool>" + (if x then "true" else "false") + "</bool>";
145
145
-
in mkIf fontconfig.enable {
146
146
-
147
147
-
# Fontconfig 2.10 backward compatibility
148
148
-
149
149
-
# Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10
150
150
-
environment.etc."fonts/fonts.conf".source =
151
151
-
pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; };
152
152
-
153
153
-
environment.etc."fonts/conf.d/98-nixos.conf".text =
154
154
-
''
145
145
+
nixosConf = ''
155
146
<?xml version='1.0'?>
156
147
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
157
148
<fontconfig>
···
179
170
</match>
180
171
181
172
<!-- Default fonts -->
182
182
-
${optionalString (fontconfig.defaultFonts.sansSerif != "") ''
173
173
+
${optionalString (fontconfig.defaultFonts.sansSerif != []) ''
183
174
<alias>
184
175
<family>sans-serif</family>
185
176
<prefer>
186
186
-
<family>${fontconfig.defaultFonts.sansSerif}</family>
177
177
+
${concatStringsSep "\n"
178
178
+
(map (font: "<family>${font}</family>")
179
179
+
fontconfig.defaultFonts.sansSerif)}
187
180
</prefer>
188
181
</alias>
189
182
''}
190
190
-
${optionalString (fontconfig.defaultFonts.serif != "") ''
183
183
+
${optionalString (fontconfig.defaultFonts.serif != []) ''
191
184
<alias>
192
185
<family>serif</family>
193
186
<prefer>
194
194
-
<family>${fontconfig.defaultFonts.serif}</family>
187
187
+
${concatStringsSep "\n"
188
188
+
(map (font: "<family>${font}</family>")
189
189
+
fontconfig.defaultFonts.serif)}
195
190
</prefer>
196
191
</alias>
197
192
''}
198
198
-
${optionalString (fontconfig.defaultFonts.monospace != "") ''
193
193
+
${optionalString (fontconfig.defaultFonts.monospace != []) ''
199
194
<alias>
200
195
<family>monospace</family>
201
196
<prefer>
202
202
-
<family>${fontconfig.defaultFonts.monospace}</family>
197
197
+
${concatStringsSep "\n"
198
198
+
(map (font: "<family>${font}</family>")
199
199
+
fontconfig.defaultFonts.monospace)}
203
200
</prefer>
204
201
</alias>
205
202
''}
···
214
211
215
212
</fontconfig>
216
213
'';
214
214
+
in mkIf fontconfig.enable {
215
215
+
216
216
+
# Fontconfig 2.10 backward compatibility
217
217
+
218
218
+
# Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10
219
219
+
environment.etc."fonts/fonts.conf".source =
220
220
+
pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; };
221
221
+
222
222
+
environment.etc."fonts/conf.d/98-nixos.conf".text = nixosConf;
217
223
218
224
# Versioned fontconfig > 2.10. Take shared fonts.conf from fontconfig.
219
225
# Otherwise specify only font directories.
···
230
236
</fontconfig>
231
237
'';
232
238
233
233
-
environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/98-nixos.conf".text =
234
234
-
''
235
235
-
<?xml version='1.0'?>
236
236
-
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
237
237
-
<fontconfig>
238
238
-
239
239
-
<!-- Default rendering settings -->
240
240
-
<match target="font">
241
241
-
<edit mode="assign" name="hinting">
242
242
-
${fcBool fontconfig.hinting.enable}
243
243
-
</edit>
244
244
-
<edit mode="assign" name="autohint">
245
245
-
${fcBool fontconfig.hinting.autohint}
246
246
-
</edit>
247
247
-
<edit mode="assign" name="hintstyle">
248
248
-
<const>hint${fontconfig.hinting.style}</const>
249
249
-
</edit>
250
250
-
<edit mode="assign" name="antialias">
251
251
-
${fcBool fontconfig.antialias}
252
252
-
</edit>
253
253
-
<edit mode="assign" name="rgba">
254
254
-
<const>${fontconfig.subpixel.rgba}</const>
255
255
-
</edit>
256
256
-
<edit mode="assign" name="lcdfilter">
257
257
-
<const>lcd${fontconfig.subpixel.lcdfilter}</const>
258
258
-
</edit>
259
259
-
</match>
260
260
-
261
261
-
<!-- Default fonts -->
262
262
-
<alias>
263
263
-
<family>sans-serif</family>
264
264
-
<prefer>
265
265
-
<family>${fontconfig.defaultFonts.sansSerif}</family>
266
266
-
</prefer>
267
267
-
</alias>
268
268
-
<alias>
269
269
-
<family>serif</family>
270
270
-
<prefer>
271
271
-
<family>${fontconfig.defaultFonts.serif}</family>
272
272
-
</prefer>
273
273
-
</alias>
274
274
-
<alias>
275
275
-
<family>monospace</family>
276
276
-
<prefer>
277
277
-
<family>${fontconfig.defaultFonts.monospace}</family>
278
278
-
</prefer>
279
279
-
</alias>
280
280
-
281
281
-
${optionalString (fontconfig.dpi != 0) ''
282
282
-
<match target="pattern">
283
283
-
<edit name="dpi" mode="assign">
284
284
-
<double>${fontconfig.dpi}</double>
285
285
-
</edit>
286
286
-
</match>
287
287
-
''}
288
288
-
289
289
-
</fontconfig>
290
290
-
'';
239
239
+
environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/98-nixos.conf".text = nixosConf;
291
240
292
241
environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/99-user.conf" = {
293
242
enable = fontconfig.includeUserConf;