lol

nixos: let fontconfig default fonts be lists of fonts

+35 -86
+35 -86
nixos/modules/config/fonts/fontconfig.nix
··· 38 38 39 39 defaultFonts = { 40 40 monospace = mkOption { 41 - type = types.str; 42 - default = "DejaVu Sans Mono"; 41 + type = types.listOf types.str; 42 + default = ["DejaVu Sans Mono"]; 43 43 description = '' 44 - System-wide default monospace font. The default is not set if the 45 - option is set to <literal>""</literal>. 44 + System-wide default monospace font(s). Multiple fonts may be 45 + listed in case multiple languages must be supported. 46 46 ''; 47 47 }; 48 48 49 49 sansSerif = mkOption { 50 - type = types.str; 51 - default = "DejaVu Sans"; 50 + type = types.listOf types.str; 51 + default = ["DejaVu Sans"]; 52 52 description = '' 53 - System-wide default sans serif font. The default is not set if the 54 - option is set to <literal>""</literal>. 53 + System-wide default sans serif font(s). Multiple fonts may be 54 + listed in case multiple languages must be supported. 55 55 ''; 56 56 }; 57 57 58 58 serif = mkOption { 59 - type = types.str; 60 - default = "DejaVu Serif"; 59 + type = types.listOf types.str; 60 + default = ["DejaVu Serif"]; 61 61 description = '' 62 - System-wide default serif font. The default is not set if the 63 - option is set to <literal>""</literal>. 62 + System-wide default serif font(s). Multiple fonts may be listed 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 - in mkIf fontconfig.enable { 146 - 147 - # Fontconfig 2.10 backward compatibility 148 - 149 - # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 150 - environment.etc."fonts/fonts.conf".source = 151 - pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; 152 - 153 - environment.etc."fonts/conf.d/98-nixos.conf".text = 154 - '' 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 - ${optionalString (fontconfig.defaultFonts.sansSerif != "") '' 173 + ${optionalString (fontconfig.defaultFonts.sansSerif != []) '' 183 174 <alias> 184 175 <family>sans-serif</family> 185 176 <prefer> 186 - <family>${fontconfig.defaultFonts.sansSerif}</family> 177 + ${concatStringsSep "\n" 178 + (map (font: "<family>${font}</family>") 179 + fontconfig.defaultFonts.sansSerif)} 187 180 </prefer> 188 181 </alias> 189 182 ''} 190 - ${optionalString (fontconfig.defaultFonts.serif != "") '' 183 + ${optionalString (fontconfig.defaultFonts.serif != []) '' 191 184 <alias> 192 185 <family>serif</family> 193 186 <prefer> 194 - <family>${fontconfig.defaultFonts.serif}</family> 187 + ${concatStringsSep "\n" 188 + (map (font: "<family>${font}</family>") 189 + fontconfig.defaultFonts.serif)} 195 190 </prefer> 196 191 </alias> 197 192 ''} 198 - ${optionalString (fontconfig.defaultFonts.monospace != "") '' 193 + ${optionalString (fontconfig.defaultFonts.monospace != []) '' 199 194 <alias> 200 195 <family>monospace</family> 201 196 <prefer> 202 - <family>${fontconfig.defaultFonts.monospace}</family> 197 + ${concatStringsSep "\n" 198 + (map (font: "<family>${font}</family>") 199 + fontconfig.defaultFonts.monospace)} 203 200 </prefer> 204 201 </alias> 205 202 ''} ··· 214 211 215 212 </fontconfig> 216 213 ''; 214 + in mkIf fontconfig.enable { 215 + 216 + # Fontconfig 2.10 backward compatibility 217 + 218 + # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 219 + environment.etc."fonts/fonts.conf".source = 220 + pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; 221 + 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 - environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/98-nixos.conf".text = 234 - '' 235 - <?xml version='1.0'?> 236 - <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> 237 - <fontconfig> 238 - 239 - <!-- Default rendering settings --> 240 - <match target="font"> 241 - <edit mode="assign" name="hinting"> 242 - ${fcBool fontconfig.hinting.enable} 243 - </edit> 244 - <edit mode="assign" name="autohint"> 245 - ${fcBool fontconfig.hinting.autohint} 246 - </edit> 247 - <edit mode="assign" name="hintstyle"> 248 - <const>hint${fontconfig.hinting.style}</const> 249 - </edit> 250 - <edit mode="assign" name="antialias"> 251 - ${fcBool fontconfig.antialias} 252 - </edit> 253 - <edit mode="assign" name="rgba"> 254 - <const>${fontconfig.subpixel.rgba}</const> 255 - </edit> 256 - <edit mode="assign" name="lcdfilter"> 257 - <const>lcd${fontconfig.subpixel.lcdfilter}</const> 258 - </edit> 259 - </match> 260 - 261 - <!-- Default fonts --> 262 - <alias> 263 - <family>sans-serif</family> 264 - <prefer> 265 - <family>${fontconfig.defaultFonts.sansSerif}</family> 266 - </prefer> 267 - </alias> 268 - <alias> 269 - <family>serif</family> 270 - <prefer> 271 - <family>${fontconfig.defaultFonts.serif}</family> 272 - </prefer> 273 - </alias> 274 - <alias> 275 - <family>monospace</family> 276 - <prefer> 277 - <family>${fontconfig.defaultFonts.monospace}</family> 278 - </prefer> 279 - </alias> 280 - 281 - ${optionalString (fontconfig.dpi != 0) '' 282 - <match target="pattern"> 283 - <edit name="dpi" mode="assign"> 284 - <double>${fontconfig.dpi}</double> 285 - </edit> 286 - </match> 287 - ''} 288 - 289 - </fontconfig> 290 - ''; 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;