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 Fontconfig reads files in folder name / file name order, so the number prepended to the configuration file name decide the order of parsing. 13 Low number means high priority. 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 */ 18 19 { config, lib, pkgs, ... }: ··· 109 </fontconfig> 110 ''; 111 112 - # prefered default fonts configuration file 113 - # priority 30 114 - genericAliasConf = 115 let genDefault = fonts: name: 116 optionalString (fonts != []) '' 117 <alias> ··· 125 </alias> 126 ''; 127 in 128 - pkgs.writeText "fc-30-nixos-generic-alias.conf" '' 129 <?xml version='1.0'?> 130 <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> 131 <fontconfig> ··· 140 </fontconfig> 141 ''; 142 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 # fontconfig configuration package 155 confPkg = pkgs.runCommand "fontconfig-conf" {} '' 156 support_folder=$out/etc/fonts ··· 170 ln -s ${latestPkg.out}/etc/fonts/conf.d/*.conf \ 171 $latest_folder/conf.d/ 172 173 # 00-nixos-cache.conf 174 ln -s ${cacheConfSupport} \ 175 $support_folder/conf.d/00-nixos-cache.conf ··· 179 ln -s ${renderConf} $support_folder/conf.d/10-nixos-rendering.conf 180 ln -s ${renderConf} $latest_folder/conf.d/10-nixos-rendering.conf 181 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 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 190 ''} 191 ''; 192 193 # Package with configuration files ··· 238 description = '' 239 Force DPI setting. Setting to <literal>0</literal> disables DPI 240 forcing; the DPI detected for the display will be used. 241 ''; 242 }; 243
··· 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 Low number means high priority. 14 15 */ 16 17 { config, lib, pkgs, ... }: ··· 107 </fontconfig> 108 ''; 109 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 = 117 let genDefault = fonts: name: 118 optionalString (fonts != []) '' 119 <alias> ··· 127 </alias> 128 ''; 129 in 130 + pkgs.writeText "fc-52-nixos-default-fonts.conf" '' 131 <?xml version='1.0'?> 132 <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> 133 <fontconfig> ··· 142 </fontconfig> 143 ''; 144 145 # fontconfig configuration package 146 confPkg = pkgs.runCommand "fontconfig-conf" {} '' 147 support_folder=$out/etc/fonts ··· 161 ln -s ${latestPkg.out}/etc/fonts/conf.d/*.conf \ 162 $latest_folder/conf.d/ 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 + 171 # 00-nixos-cache.conf 172 ln -s ${cacheConfSupport} \ 173 $support_folder/conf.d/00-nixos-cache.conf ··· 177 ln -s ${renderConf} $support_folder/conf.d/10-nixos-rendering.conf 178 ln -s ${renderConf} $latest_folder/conf.d/10-nixos-rendering.conf 179 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 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 ''} 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 195 ''; 196 197 # Package with configuration files ··· 242 description = '' 243 Force DPI setting. Setting to <literal>0</literal> disables DPI 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. 254 ''; 255 }; 256
-1
pkgs/development/libraries/fontconfig/default.nix
··· 66 67 postInstall = '' 68 cd "$out/etc/fonts" 69 - rm conf.d/{50-user,51-local}.conf 70 "${libxslt.bin}/bin/xsltproc" --stringparam fontDirectories "${fontbhttf}" \ 71 --stringparam fontconfigConfigVersion "${configVersion}" \ 72 --path $out/share/xml/fontconfig \
··· 66 67 postInstall = '' 68 cd "$out/etc/fonts" 69 "${libxslt.bin}/bin/xsltproc" --stringparam fontDirectories "${fontbhttf}" \ 70 --stringparam fontconfigConfigVersion "${configVersion}" \ 71 --path $out/share/xml/fontconfig \