diff options
author | obadz <obadz-git@obadz.com> | 2016-07-15 20:43:42 +0200 |
---|---|---|
committer | obadz <obadz-git@obadz.com> | 2016-07-15 20:44:21 +0200 |
commit | cfc0a5415b935fb50241ab1b571771c2f793695c (patch) | |
tree | fc7abf4e1557dd62be28154c561d096399e522d6 /nixos/modules/config/fonts | |
parent | 1b0e82d6ff86e4f9f072a16a71d443c2bea75633 (diff) |
Revert "fontconfig: fix etc priority"
This reverts commit 1e53d4a7776acbf61f42c094c103652c8068ad64.
Closes #16983
cc @vcunat @ericsagnes @dezgeg
Diffstat (limited to 'nixos/modules/config/fonts')
-rw-r--r-- | nixos/modules/config/fonts/fontconfig-ultimate.nix | 153 | ||||
-rw-r--r-- | nixos/modules/config/fonts/fontconfig.nix | 262 |
2 files changed, 199 insertions, 216 deletions
diff --git a/nixos/modules/config/fonts/fontconfig-ultimate.nix b/nixos/modules/config/fonts/fontconfig-ultimate.nix index 47d7cc5924d4..02568f9de51e 100644 --- a/nixos/modules/config/fonts/fontconfig-ultimate.nix +++ b/nixos/modules/config/fonts/fontconfig-ultimate.nix @@ -3,84 +3,6 @@ with lib; let fcBool = x: if x then "<bool>true</bool>" else "<bool>false</bool>"; - cfg = config.fonts.fontconfig.ultimate; - fontconfigUltimateConf = pkgs.writeText "ultimate-conf" '' - <?xml version="1.0"?> - <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> - <fontconfig> - - ${optionalString (!cfg.allowBitmaps) '' - <!-- Reject bitmap fonts --> - <selectfont> - <rejectfont> - <pattern> - <patelt name="scalable"><bool>false</bool></patelt> - </pattern> - </rejectfont> - </selectfont> - ''} - - ${optionalString cfg.allowType1 '' - <!-- Reject Type 1 fonts --> - <selectfont> - <rejectfont> - <pattern> - <patelt name="fontformat"> - <string>Type 1</string> - </patelt> - </pattern> - </rejectfont> - </selectfont> - ''} - - <!-- Use embedded bitmaps in fonts like Calibri? --> - <match target="font"> - <edit name="embeddedbitmap" mode="assign"> - ${fcBool cfg.useEmbeddedBitmaps} - </edit> - </match> - - <!-- Force autohint always --> - <match target="font"> - <edit name="force_autohint" mode="assign"> - ${fcBool cfg.forceAutohint} - </edit> - </match> - - <!-- Render some monospace TTF fonts as bitmaps --> - <match target="pattern"> - <edit name="bitmap_monospace" mode="assign"> - ${fcBool cfg.renderMonoTTFAsBitmap} - </edit> - </match> - - </fontconfig> - ''; - confPkg = - let version = pkgs.fontconfig.configVersion; - in pkgs.runCommand "font-ultimate-conf" {} '' - mkdir -p $out/etc/fonts/{,${version}/}conf.d/ - - cp ${fontconfigUltimateConf} \ - $out/etc/fonts/conf.d/52-fontconfig-ultimate.conf - - cp ${fontconfigUltimateConf} \ - $out/etc/fonts/${version}/conf.d/52-fontconfig-ultimate.conf - - ${optionalString (cfg.substitutions != "none") '' - cp ${pkgs.fontconfig-ultimate.confd}/etc/fonts/presets/${cfg.substitutions}/*.conf \ - $out/etc/fonts/conf.d/ - cp ${pkgs.fontconfig-ultimate.confd}/etc/fonts/presets/${cfg.substitutions}/*.conf \ - $out/etc/fonts/${version}/conf.d/ - ''} - - ln -s ${pkgs.fontconfig-ultimate.confd}/etc/fonts/conf.d/*.conf \ - $out/etc/fonts/conf.d/ - - ln -s ${pkgs.fontconfig-ultimate.confd}/etc/fonts/conf.d/*.conf \ - $out/etc/fonts/${version}/conf.d/ - ''; - in { @@ -193,11 +115,78 @@ in }; - config = mkIf (config.fonts.fontconfig.enable && cfg.enable) { + config = + let ultimate = config.fonts.fontconfig.ultimate; + fontconfigUltimateConf = '' + <?xml version="1.0"?> + <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> + <fontconfig> + + ${optionalString (!ultimate.allowBitmaps) '' + <!-- Reject bitmap fonts --> + <selectfont> + <rejectfont> + <pattern> + <patelt name="scalable"><bool>false</bool></patelt> + </pattern> + </rejectfont> + </selectfont> + ''} + + ${optionalString ultimate.allowType1 '' + <!-- Reject Type 1 fonts --> + <selectfont> + <rejectfont> + <pattern> + <patelt name="fontformat"> + <string>Type 1</string> + </patelt> + </pattern> + </rejectfont> + </selectfont> + ''} + + <!-- Use embedded bitmaps in fonts like Calibri? --> + <match target="font"> + <edit name="embeddedbitmap" mode="assign"> + ${fcBool ultimate.useEmbeddedBitmaps} + </edit> + </match> + + <!-- Force autohint always --> + <match target="font"> + <edit name="force_autohint" mode="assign"> + ${fcBool ultimate.forceAutohint} + </edit> + </match> + + <!-- Render some monospace TTF fonts as bitmaps --> + <match target="pattern"> + <edit name="bitmap_monospace" mode="assign"> + ${fcBool ultimate.renderMonoTTFAsBitmap} + </edit> + </match> + + ${optionalString (ultimate.substitutions != "none") '' + <!-- Type 1 font substitutions --> + <include ignore_missing="yes">${pkgs.fontconfig-ultimate.confd}/etc/fonts/presets/${ultimate.substitutions}</include> + ''} + + <include ignore_missing="yes">${pkgs.fontconfig-ultimate.confd}/etc/fonts/conf.d</include> + + </fontconfig> + ''; + in mkIf (config.fonts.fontconfig.enable && ultimate.enable) { + + environment.etc."fonts/conf.d/52-fontconfig-ultimate.conf" = { + text = fontconfigUltimateConf; + }; + + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/52-fontconfig-ultimate.conf" = { + text = fontconfigUltimateConf; + }; - fonts.fontconfig.confPkgs = [ confPkg ]; - - environment.variables = cfg.rendering; + environment.variables = ultimate.rendering; }; diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index fcf5add45197..1eaebe4b2bbd 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -2,121 +2,6 @@ with lib; -let cfg = config.fonts.fontconfig; - fcBool = x: "<bool>" + (if x then "true" else "false") + "</bool>"; - renderConf = pkgs.writeText "render-conf" '' - <?xml version='1.0'?> - <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> - <fontconfig> - - <!-- Default rendering settings --> - <match target="font"> - <edit mode="assign" name="hinting"> - ${fcBool cfg.hinting.enable} - </edit> - <edit mode="assign" name="autohint"> - ${fcBool cfg.hinting.autohint} - </edit> - <edit mode="assign" name="hintstyle"> - <const>hint${cfg.hinting.style}</const> - </edit> - <edit mode="assign" name="antialias"> - ${fcBool cfg.antialias} - </edit> - <edit mode="assign" name="rgba"> - <const>${cfg.subpixel.rgba}</const> - </edit> - <edit mode="assign" name="lcdfilter"> - <const>lcd${cfg.subpixel.lcdfilter}</const> - </edit> - </match> - - ${optionalString (cfg.dpi != 0) '' - <match target="pattern"> - <edit name="dpi" mode="assign"> - <double>${toString cfg.dpi}</double> - </edit> - </match> - ''} - - </fontconfig> - ''; - genericAliasConf = - let genDefault = fonts: name: - optionalString (fonts != []) '' - <alias> - <family>${name}</family> - <prefer> - ${concatStringsSep "" - (map (font: '' - <family>${font}</family> - '') fonts)} - </prefer> - </alias> - ''; - in - pkgs.writeText "generic-alias-conf" '' - <?xml version='1.0'?> - <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> - <fontconfig> - - <!-- Default fonts --> - ${genDefault cfg.defaultFonts.sansSerif "sans-serif"} - - ${genDefault cfg.defaultFonts.serif "serif"} - - ${genDefault cfg.defaultFonts.monospace "monospace"} - - </fontconfig> - ''; - cacheConf = let - cache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; }; - in - pkgs.writeText "cache-conf" '' - <?xml version='1.0'?> - <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> - <fontconfig> - <!-- Font directories --> - ${concatStringsSep "\n" (map (font: "<dir>${font}</dir>") config.fonts.fonts)} - <!-- Pre-generated font caches --> - <cachedir>${cache pkgs.fontconfig}</cachedir> - ${optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) '' - <cachedir>${cache pkgs.pkgsi686Linux.fontconfig}</cachedir> - ''} - </fontconfig> - ''; - userConf = pkgs.writeText "user-conf" '' - <?xml version="1.0"?> - <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> - <fontconfig> - <include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include> - <include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include> - </fontconfig> - ''; - fontsConf = pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; - confPkg = - let version = pkgs.fontconfig.configVersion; - in pkgs.runCommand "fontconfig-conf" {} '' - mkdir -p $out/etc/fonts/{,${version}/}conf.d - - ln -s ${fontsConf} $out/etc/fonts/fonts.conf - - ln -s ${pkgs.fontconfig.out}/etc/fonts/fonts.conf $out/etc/fonts/${version}/fonts.conf - ln -s ${pkgs.fontconfig.out}/etc/fonts/conf.d/* $out/etc/fonts/${version}/conf.d/ - - ln -s ${renderConf} $out/etc/fonts/conf.d/10-nixos-rendering.conf - ln -s ${genericAliasConf} $out/etc/fonts/conf.d/60-nixos-generic-alias.conf - - ln -s ${cacheConf} $out/etc/fonts/${version}/conf.d/00-nixos.conf - - ln -s ${renderConf} $out/etc/fonts/${version}/conf.d/10-nixos-rendering.conf - ln -s ${genericAliasConf} $out/etc/fonts/${version}/conf.d/30-nixos-generic-alias.conf - - ${optionalString cfg.includeUserConf - "ln -s ${userConf} $out/etc/fonts/${version}/conf.d/99-user.conf"} - - ''; -in { options = { @@ -136,15 +21,6 @@ in ''; }; - confPkgs = mkOption { - internal = true; - type = with types; listOf path; - default = [ ]; - description = '' - Fontconfig configuration packages. - ''; - }; - antialias = mkOption { type = types.bool; default = true; @@ -267,17 +143,135 @@ in }; - config = mkIf cfg.enable { - fonts.fontconfig.confPkgs = [ confPkg ]; + config = + let fontconfig = config.fonts.fontconfig; + fcBool = x: "<bool>" + (if x then "true" else "false") + "</bool>"; + renderConf = '' + <?xml version='1.0'?> + <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> + <fontconfig> + + <!-- Default rendering settings --> + <match target="font"> + <edit mode="assign" name="hinting"> + ${fcBool fontconfig.hinting.enable} + </edit> + <edit mode="assign" name="autohint"> + ${fcBool fontconfig.hinting.autohint} + </edit> + <edit mode="assign" name="hintstyle"> + <const>hint${fontconfig.hinting.style}</const> + </edit> + <edit mode="assign" name="antialias"> + ${fcBool fontconfig.antialias} + </edit> + <edit mode="assign" name="rgba"> + <const>${fontconfig.subpixel.rgba}</const> + </edit> + <edit mode="assign" name="lcdfilter"> + <const>lcd${fontconfig.subpixel.lcdfilter}</const> + </edit> + </match> + + ${optionalString (fontconfig.dpi != 0) '' + <match target="pattern"> + <edit name="dpi" mode="assign"> + <double>${toString fontconfig.dpi}</double> + </edit> + </match> + ''} + + </fontconfig> + ''; + genericAliasConf = '' + <?xml version='1.0'?> + <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> + <fontconfig> + + <!-- Default fonts --> + ${optionalString (fontconfig.defaultFonts.sansSerif != []) '' + <alias> + <family>sans-serif</family> + <prefer> + ${concatStringsSep "\n" + (map (font: "<family>${font}</family>") + fontconfig.defaultFonts.sansSerif)} + </prefer> + </alias> + ''} + ${optionalString (fontconfig.defaultFonts.serif != []) '' + <alias> + <family>serif</family> + <prefer> + ${concatStringsSep "\n" + (map (font: "<family>${font}</family>") + fontconfig.defaultFonts.serif)} + </prefer> + </alias> + ''} + ${optionalString (fontconfig.defaultFonts.monospace != []) '' + <alias> + <family>monospace</family> + <prefer> + ${concatStringsSep "\n" + (map (font: "<family>${font}</family>") + fontconfig.defaultFonts.monospace)} + </prefer> + </alias> + ''} + + </fontconfig> + ''; + in mkIf fontconfig.enable { + + # Fontconfig 2.10 backward compatibility + + # Bring in the default (upstream) fontconfig configuration, only for fontconfig 2.10 + environment.etc."fonts/fonts.conf".source = + pkgs.makeFontsConf { fontconfig = pkgs.fontconfig_210; fontDirectories = config.fonts.fonts; }; + + environment.etc."fonts/conf.d/10-nixos-rendering.conf".text = renderConf; + environment.etc."fonts/conf.d/60-nixos-generic-alias.conf".text = genericAliasConf; + + # Versioned fontconfig > 2.10. Take shared fonts.conf from fontconfig. + # Otherwise specify only font directories. + environment.etc."fonts/${pkgs.fontconfig.configVersion}/fonts.conf".source = + "${pkgs.fontconfig.out}/etc/fonts/fonts.conf"; + + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/00-nixos.conf".text = + let + cache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; }; + in '' + <?xml version='1.0'?> + <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'> + <fontconfig> + <!-- Font directories --> + ${concatStringsSep "\n" (map (font: "<dir>${font}</dir>") config.fonts.fonts)} + <!-- Pre-generated font caches --> + <cachedir>${cache pkgs.fontconfig}</cachedir> + ${optionalString (pkgs.stdenv.isx86_64 && config.fonts.fontconfig.cache32Bit) '' + <cachedir>${cache pkgs.pkgsi686Linux.fontconfig}</cachedir> + ''} + </fontconfig> + ''; + + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/10-nixos-rendering.conf".text = renderConf; + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/60-nixos-generic-alias.conf".text = genericAliasConf; + + environment.etc."fonts/${pkgs.fontconfig.configVersion}/conf.d/99-user.conf" = { + enable = fontconfig.includeUserConf; + text = '' + <?xml version="1.0"?> + <!DOCTYPE fontconfig SYSTEM "fonts.dtd"> + <fontconfig> + <include ignore_missing="yes" prefix="xdg">fontconfig/conf.d</include> + <include ignore_missing="yes" prefix="xdg">fontconfig/fonts.conf</include> + </fontconfig> + ''; + }; - environment.etc.fonts.source = - let fontConf = pkgs.symlinkJoin { - name = "fontconfig-etc"; - paths = cfg.confPkgs; - }; - in "${fontConf}/etc/fonts/"; + environment.systemPackages = [ pkgs.fontconfig ]; - environment.systemPackages = [ pkgs.fontconfig ]; - }; + }; } |