at 18.09-beta 2.6 kB view raw
1{ config, pkgs, lib, ... }: 2 3with lib; 4 5let cfg = config.fonts.fontconfig.ultimate; 6 7 latestVersion = pkgs.fontconfig.configVersion; 8 9 # The configuration to be included in /etc/font/ 10 confPkg = pkgs.runCommand "font-ultimate-conf" {} '' 11 support_folder=$out/etc/fonts/conf.d 12 latest_folder=$out/etc/fonts/${latestVersion}/conf.d 13 14 mkdir -p $support_folder 15 mkdir -p $latest_folder 16 17 # fontconfig ultimate substitutions 18 ${optionalString (cfg.substitutions != "none") '' 19 ln -s ${pkgs.fontconfig-ultimate}/etc/fonts/presets/${cfg.substitutions}/*.conf \ 20 $support_folder 21 ln -s ${pkgs.fontconfig-ultimate}/etc/fonts/presets/${cfg.substitutions}/*.conf \ 22 $latest_folder 23 ''} 24 25 # fontconfig ultimate various configuration files 26 ln -s ${pkgs.fontconfig-ultimate}/etc/fonts/conf.d/*.conf \ 27 $support_folder 28 ln -s ${pkgs.fontconfig-ultimate}/etc/fonts/conf.d/*.conf \ 29 $latest_folder 30 ''; 31 32in 33{ 34 35 options = { 36 37 fonts = { 38 39 fontconfig = { 40 41 ultimate = { 42 enable = mkOption { 43 type = types.bool; 44 default = false; 45 description = '' 46 Enable fontconfig-ultimate settings (formerly known as 47 Infinality). Besides the customizable settings in this NixOS 48 module, fontconfig-ultimate also provides many font-specific 49 rendering tweaks. 50 ''; 51 }; 52 53 substitutions = mkOption { 54 type = types.enum ["free" "combi" "ms" "none"]; 55 default = "free"; 56 description = '' 57 Font substitutions to replace common Type 1 fonts with nicer 58 TrueType fonts. <literal>free</literal> uses free fonts, 59 <literal>ms</literal> uses Microsoft fonts, 60 <literal>combi</literal> uses a combination, and 61 <literal>none</literal> disables the substitutions. 62 ''; 63 }; 64 65 preset = mkOption { 66 type = types.enum ["ultimate1" "ultimate2" "ultimate3" "ultimate4" "ultimate5" "osx" "windowsxp"]; 67 default = "ultimate3"; 68 description = '' 69 FreeType rendering settings preset. Any of the presets may be 70 customized by setting environment variables. 71 ''; 72 }; 73 }; 74 }; 75 }; 76 77 }; 78 79 config = mkIf (config.fonts.fontconfig.enable && cfg.enable) { 80 81 fonts.fontconfig.confPackages = [ confPkg ]; 82 environment.variables."INFINALITY_FT" = cfg.preset; 83 84 }; 85 86}