fontconfig module: respect upstream definitions

authored by

Eric Sagnes and committed by
Nikolay Amiantov
e80e8b9d cd2948a7

+37 -25
+37 -24
nixos/modules/config/fonts/fontconfig.nix
··· 12 12 Fontconfig reads files in folder name / file name order, so the number prepended to the configuration file name decide the order of parsing. 13 13 Low number means high priority. 14 14 15 - Default fonts should have a high priority (low number) to be at the head of the preferred fonts list, fontconfig advise the 30~40 range. 16 - 17 15 */ 18 16 19 17 { config, lib, pkgs, ... }: ··· 109 107 </fontconfig> 110 108 ''; 111 109 112 - # prefered default fonts configuration file 113 - # priority 30 114 - genericAliasConf = 110 + # local configuration file 111 + # priority 51 112 + localConf = pkgs.writeText "fc-local.conf" cfg.localConf; 113 + 114 + # default fonts configuration file 115 + # priority 52 116 + defaultFontsConf = 115 117 let genDefault = fonts: name: 116 118 optionalString (fonts != []) '' 117 119 <alias> ··· 125 127 </alias> 126 128 ''; 127 129 in 128 - pkgs.writeText "fc-30-nixos-generic-alias.conf" '' 130 + pkgs.writeText "fc-52-nixos-default-fonts.conf" '' 129 131 <?xml version='1.0'?> 130 132 <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> 131 133 <fontconfig> ··· 140 142 </fontconfig> 141 143 ''; 142 144 143 - # user settings configuration file 144 - # priority 99 145 - userConf = pkgs.writeText "fc-99-user.conf" '' 146 - <?xml version="1.0"?> 147 - <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> 148 - <fontconfig> 149 - <include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include> 150 - <include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include> 151 - </fontconfig> 152 - ''; 153 - 154 145 # fontconfig configuration package 155 146 confPkg = pkgs.runCommand "fontconfig-conf" {} '' 156 147 support_folder=$out/etc/fonts ··· 170 161 ln -s ${latestPkg.out}/etc/fonts/conf.d/*.conf \ 171 162 $latest_folder/conf.d/ 172 163 164 + # update latest 51-local.conf path to look at the latest local.conf 165 + rm $latest_folder/conf.d/51-local.conf 166 + 167 + substitute ${latestPkg.out}/etc/fonts/conf.d/51-local.conf \ 168 + $latest_folder/conf.d/51-local.conf \ 169 + --replace local.conf /etc/fonts/${latestVersion}/local.conf 170 + 173 171 # 00-nixos-cache.conf 174 172 ln -s ${cacheConfSupport} \ 175 173 $support_folder/conf.d/00-nixos-cache.conf ··· 179 177 ln -s ${renderConf} $support_folder/conf.d/10-nixos-rendering.conf 180 178 ln -s ${renderConf} $latest_folder/conf.d/10-nixos-rendering.conf 181 179 182 - # 30-nixos-generic-alias.conf 183 - ln -s ${genericAliasConf} $support_folder/conf.d/30-nixos-generic-alias.conf 184 - ln -s ${genericAliasConf} $latest_folder/conf.d/30-nixos-generic-alias.conf 180 + # 50-user.conf 181 + ${optionalString (! cfg.includeUserConf) '' 182 + rm $support_folder/conf.d/50-user.conf 183 + rm $latest_folder/conf.d/50-user.conf 184 + ''} 185 185 186 - # 99-user.conf 187 - ${optionalString cfg.includeUserConf '' 188 - ln -s ${userConf} $support_folder/conf.d/99-user.conf 189 - ln -s ${userConf} $latest_folder/conf.d/99-user.conf 186 + # local.conf (indirect priority 51) 187 + ${optionalString (cfg.localConf != "") '' 188 + ln -s ${localConf} $support_folder/local.conf 189 + ln -s ${localConf} $latest_folder/local.conf 190 190 ''} 191 + 192 + # 52-nixos-default-fonts.conf 193 + ln -s ${defaultFontsConf} $support_folder/conf.d/52-nixos-default-fonts.conf 194 + ln -s ${defaultFontsConf} $latest_folder/conf.d/52-nixos-default-fonts.conf 191 195 ''; 192 196 193 197 # Package with configuration files ··· 238 242 description = '' 239 243 Force DPI setting. Setting to <literal>0</literal> disables DPI 240 244 forcing; the DPI detected for the display will be used. 245 + ''; 246 + }; 247 + 248 + localConf = mkOption { 249 + type = types.lines; 250 + default = ""; 251 + description = '' 252 + System-wide customization file contents, has higher priority than 253 + <literal>defaultFonts</literal> settings. 241 254 ''; 242 255 }; 243 256
-1
pkgs/development/libraries/fontconfig/default.nix
··· 66 66 67 67 postInstall = '' 68 68 cd "$out/etc/fonts" 69 - rm conf.d/{50-user,51-local}.conf 70 69 "${libxslt.bin}/bin/xsltproc" --stringparam fontDirectories "${fontbhttf}" \ 71 70 --stringparam fontconfigConfigVersion "${configVersion}" \ 72 71 --path $out/share/xml/fontconfig \