/*
-NixOS support 2 fontconfig versions, "support" and "latest".
+ NixOS support 2 fontconfig versions, "support" and "latest".
-- "latest" refers to default fontconfig package (pkgs.fontconfig).
+ - "latest" refers to default fontconfig package (pkgs.fontconfig).
configuration files are linked to /etc/fonts/VERSION/conf.d/
-- "support" refers to supportPkg (pkgs."fontconfig_${supportVersion}").
+ - "support" refers to supportPkg (pkgs."fontconfig_${supportVersion}").
configuration files are linked to /etc/fonts/conf.d/
-This module generates a package containing configuration files and link it in /etc/fonts.
+ This module generates a package containing configuration files and link it in /etc/fonts.
-Fontconfig reads files in folder name / file name order, so the number prepended to the configuration file name decide the order of parsing.
-Low number means high priority.
+ Fontconfig reads files in folder name / file name order, so the number prepended to the configuration file name decide the order of parsing.
+ Low number means high priority.
*/
# back-supported fontconfig version and package
# version is used for font cache generation
supportVersion = "210";
- supportPkg = pkgs."fontconfig_${supportVersion}";
+ supportPkg = pkgs."fontconfig_${supportVersion}";
# latest fontconfig version and package
# version is used for configuration folder name, /etc/fonts/VERSION/
# note: format differs from supportVersion and can not be used with makeCacheConf
- latestVersion = pkgs.fontconfig.configVersion;
- latestPkg = pkgs.fontconfig;
+ latestVersion = pkgs.fontconfig.configVersion;
+ latestPkg = pkgs.fontconfig;
# supported version fonts.conf
supportFontsConf = pkgs.makeFontsConf { fontconfig = supportPkg; fontDirectories = config.fonts.fonts; };
# version dependent
# priority 0
cacheConfSupport = makeCacheConf { version = supportVersion; };
- cacheConfLatest = makeCacheConf {};
+ cacheConfLatest = makeCacheConf { };
# generate the font cache setting file for a fontconfig version
# use latest when no version is passed
# looking things up.
makeCacheConf = { version ? null }:
let
- fcPackage = if version == null
- then "fontconfig"
- else "fontconfig_${version}";
+ fcPackage =
+ if version == null
+ then "fontconfig"
+ else "fontconfig_${version}";
makeCache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; };
- cache = makeCache pkgs.${fcPackage};
- cache32 = makeCache pkgs.pkgsi686Linux.${fcPackage};
+ cache = makeCache pkgs.${fcPackage};
+ cache32 = makeCache pkgs.pkgsi686Linux.${fcPackage};
in
pkgs.writeText "fc-00-nixos-cache.conf" ''
<?xml version='1.0'?>
# default fonts configuration file
# priority 52
defaultFontsConf =
- let genDefault = fonts: name:
- optionalString (fonts != []) ''
- <alias binding="same">
- <family>${name}</family>
- <prefer>
- ${concatStringsSep ""
- (map (font: ''
- <family>${font}</family>
- '') fonts)}
- </prefer>
- </alias>
- '';
+ let
+ genDefault = fonts: name:
+ optionalString (fonts != [ ]) ''
+ <alias binding="same">
+ <family>${name}</family>
+ <prefer>
+ ${concatStringsSep ""
+ (map (font: ''
+ <family>${font}</family>
+ '') fonts)}
+ </prefer>
+ </alias>
+ '';
in
pkgs.writeText "fc-52-nixos-default-fonts.conf" ''
- <?xml version='1.0'?>
- <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
- <fontconfig>
+ <?xml version='1.0'?>
+ <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
+ <fontconfig>
- <!-- Default fonts -->
- ${genDefault cfg.defaultFonts.sansSerif "sans-serif"}
+ <!-- Default fonts -->
+ ${genDefault cfg.defaultFonts.sansSerif "sans-serif"}
- ${genDefault cfg.defaultFonts.serif "serif"}
+ ${genDefault cfg.defaultFonts.serif "serif"}
- ${genDefault cfg.defaultFonts.monospace "monospace"}
+ ${genDefault cfg.defaultFonts.monospace "monospace"}
- ${genDefault cfg.defaultFonts.emoji "emoji"}
+ ${genDefault cfg.defaultFonts.emoji "emoji"}
- </fontconfig>
- '';
+ </fontconfig>
+ '';
# bitmap font options
# priority 53
'';
# fontconfig configuration package
- confPkg = pkgs.runCommand "fontconfig-conf" {
- preferLocalBuild = true;
- } ''
+ confPkg = pkgs.runCommand "fontconfig-conf"
+ {
+ preferLocalBuild = true;
+ } ''
support_folder=$out/etc/fonts/conf.d
latest_folder=$out/etc/fonts/${latestVersion}/conf.d
# Package with configuration files
# this merge all the packages in the fonts.fontconfig.confPackages list
fontconfigEtc = pkgs.buildEnv {
- name = "fontconfig-etc";
+ name = "fontconfig-etc";
paths = cfg.confPackages;
ignoreCollisions = true;
};
(mkRemovedOptionModule [ "fonts" "fontconfig" "forceAutohint" ] "")
(mkRemovedOptionModule [ "fonts" "fontconfig" "renderMonoTTFAsBitmap" ] "")
] ++ lib.forEach [ "enable" "substitutions" "preset" ]
- (opt: lib.mkRemovedOptionModule [ "fonts" "fontconfig" "ultimate" "${opt}" ] ''
- The fonts.fontconfig.ultimate module and configuration is obsolete.
- The repository has since been archived and activity has ceased.
- https://github.com/bohoomil/fontconfig-ultimate/issues/171.
- No action should be needed for font configuration, as the fonts.fontconfig
- module is already used by default.
- '');
+ (opt: lib.mkRemovedOptionModule [ "fonts" "fontconfig" "ultimate" "${opt}" ] ''
+ The fonts.fontconfig.ultimate module and configuration is obsolete.
+ The repository has since been archived and activity has ceased.
+ https://github.com/bohoomil/fontconfig-ultimate/issues/171.
+ No action should be needed for font configuration, as the fonts.fontconfig
+ module is already used by default.
+ '');
options = {
confPackages = mkOption {
internal = true;
- type = with types; listOf path;
- default = [ ];
+ type = with types; listOf path;
+ default = [ ];
description = ''
Fontconfig configuration packages.
'';
defaultFonts = {
monospace = mkOption {
type = types.listOf types.str;
- default = ["DejaVu Sans Mono"];
+ default = [ "DejaVu Sans Mono" ];
description = ''
System-wide default monospace font(s). Multiple fonts may be
listed in case multiple languages must be supported.
sansSerif = mkOption {
type = types.listOf types.str;
- default = ["DejaVu Sans"];
+ default = [ "DejaVu Sans" ];
description = ''
System-wide default sans serif font(s). Multiple fonts may be
listed in case multiple languages must be supported.
serif = mkOption {
type = types.listOf types.str;
- default = ["DejaVu Serif"];
+ default = [ "DejaVu Serif" ];
description = ''
System-wide default serif font(s). Multiple fonts may be listed
in case multiple languages must be supported.
emoji = mkOption {
type = types.listOf types.str;
- default = ["Noto Color Emoji"];
+ default = [ "Noto Color Emoji" ];
description = ''
System-wide default emoji font(s). Multiple fonts may be listed
in case a font does not support all emoji.
rgba = mkOption {
default = "rgb";
- type = types.enum ["rgb" "bgr" "vrgb" "vbgr" "none"];
+ type = types.enum [ "rgb" "bgr" "vrgb" "vbgr" "none" ];
description = ''
Subpixel order. The overwhelming majority of displays are
<literal>rgb</literal> in their normal orientation. Select
lcdfilter = mkOption {
default = "default";
- type = types.enum ["none" "default" "light" "legacy"];
+ type = types.enum [ "none" "default" "light" "legacy" ];
description = ''
FreeType LCD filter. At high resolution (> 200 DPI), LCD filtering
has no visible effect; users of such displays may want to select
};
config = mkMerge [
(mkIf cfg.enable {
- environment.systemPackages = [ pkgs.fontconfig ];
- environment.etc.fonts.source = "${fontconfigEtc}/etc/fonts/";
+ environment.systemPackages = [ pkgs.fontconfig ];
+ environment.etc.fonts.source = "${fontconfigEtc}/etc/fonts/";
security.apparmor.includes."abstractions/fonts" = ''
# fonts.conf
r ${supportFontsConf}