diff --git a/nixos/modules/config/fonts/fontconfig-ultimate.nix b/nixos/modules/config/fonts/fontconfig-ultimate.nix
index 02568f9de51e..47d7cc5924d4 100644
--- a/nixos/modules/config/fonts/fontconfig-ultimate.nix
+++ b/nixos/modules/config/fonts/fontconfig-ultimate.nix
@@ -3,6 +3,84 @@
with lib;
let fcBool = x: if x then "true" else "false";
+ cfg = config.fonts.fontconfig.ultimate;
+ fontconfigUltimateConf = pkgs.writeText "ultimate-conf" ''
+
+
+
+
+ ${optionalString (!cfg.allowBitmaps) ''
+
+
+
+
+ false
+
+
+
+ ''}
+
+ ${optionalString cfg.allowType1 ''
+
+
+
+
+
+ Type 1
+
+
+
+
+ ''}
+
+
+
+
+ ${fcBool cfg.useEmbeddedBitmaps}
+
+
+
+
+
+
+ ${fcBool cfg.forceAutohint}
+
+
+
+
+
+
+ ${fcBool cfg.renderMonoTTFAsBitmap}
+
+
+
+
+ '';
+ 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
{
@@ -115,78 +193,11 @@ in
};
- config =
- let ultimate = config.fonts.fontconfig.ultimate;
- fontconfigUltimateConf = ''
-
-
-
+ config = mkIf (config.fonts.fontconfig.enable && cfg.enable) {
- ${optionalString (!ultimate.allowBitmaps) ''
-
-
-
-
- false
-
-
-
- ''}
-
- ${optionalString ultimate.allowType1 ''
-
-
-
-
-
- Type 1
-
-
-
-
- ''}
-
-
-
-
- ${fcBool ultimate.useEmbeddedBitmaps}
-
-
-
-
-
-
- ${fcBool ultimate.forceAutohint}
-
-
-
-
-
-
- ${fcBool ultimate.renderMonoTTFAsBitmap}
-
-
-
- ${optionalString (ultimate.substitutions != "none") ''
-
- ${pkgs.fontconfig-ultimate.confd}/etc/fonts/presets/${ultimate.substitutions}
- ''}
-
- ${pkgs.fontconfig-ultimate.confd}/etc/fonts/conf.d
-
-
- '';
- 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;
- };
-
- environment.variables = ultimate.rendering;
+ fonts.fontconfig.confPkgs = [ confPkg ];
+
+ environment.variables = cfg.rendering;
};
diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix
index 1eaebe4b2bbd..fcf5add45197 100644
--- a/nixos/modules/config/fonts/fontconfig.nix
+++ b/nixos/modules/config/fonts/fontconfig.nix
@@ -2,6 +2,121 @@
with lib;
+let cfg = config.fonts.fontconfig;
+ fcBool = x: "" + (if x then "true" else "false") + "";
+ renderConf = pkgs.writeText "render-conf" ''
+
+
+
+
+
+
+
+ ${fcBool cfg.hinting.enable}
+
+
+ ${fcBool cfg.hinting.autohint}
+
+
+ hint${cfg.hinting.style}
+
+
+ ${fcBool cfg.antialias}
+
+
+ ${cfg.subpixel.rgba}
+
+
+ lcd${cfg.subpixel.lcdfilter}
+
+
+
+ ${optionalString (cfg.dpi != 0) ''
+
+
+ ${toString cfg.dpi}
+
+
+ ''}
+
+
+ '';
+ genericAliasConf =
+ let genDefault = fonts: name:
+ optionalString (fonts != []) ''
+
+ ${name}
+
+ ${concatStringsSep ""
+ (map (font: ''
+ ${font}
+ '') fonts)}
+
+
+ '';
+ in
+ pkgs.writeText "generic-alias-conf" ''
+
+
+
+
+
+ ${genDefault cfg.defaultFonts.sansSerif "sans-serif"}
+
+ ${genDefault cfg.defaultFonts.serif "serif"}
+
+ ${genDefault cfg.defaultFonts.monospace "monospace"}
+
+
+ '';
+ cacheConf = let
+ cache = fontconfig: pkgs.makeFontsCache { inherit fontconfig; fontDirectories = config.fonts.fonts; };
+ in
+ pkgs.writeText "cache-conf" ''
+
+
+
+
+ ${concatStringsSep "\n" (map (font: "${font}") config.fonts.fonts)}
+
+ ${cache pkgs.fontconfig}
+ ${optionalString (pkgs.stdenv.isx86_64 && cfg.cache32Bit) ''
+ ${cache pkgs.pkgsi686Linux.fontconfig}
+ ''}
+
+ '';
+ userConf = pkgs.writeText "user-conf" ''
+
+
+
+ fontconfig/conf.d
+ fontconfig/fonts.conf
+
+ '';
+ 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 = {
@@ -21,6 +136,15 @@ with lib;
'';
};
+ confPkgs = mkOption {
+ internal = true;
+ type = with types; listOf path;
+ default = [ ];
+ description = ''
+ Fontconfig configuration packages.
+ '';
+ };
+
antialias = mkOption {
type = types.bool;
default = true;
@@ -143,135 +267,17 @@ with lib;
};
- config =
- let fontconfig = config.fonts.fontconfig;
- fcBool = x: "" + (if x then "true" else "false") + "";
- renderConf = ''
-
-
-
+ config = mkIf cfg.enable {
+ fonts.fontconfig.confPkgs = [ confPkg ];
-
-
-
- ${fcBool fontconfig.hinting.enable}
-
-
- ${fcBool fontconfig.hinting.autohint}
-
-
- hint${fontconfig.hinting.style}
-
-
- ${fcBool fontconfig.antialias}
-
-
- ${fontconfig.subpixel.rgba}
-
-
- lcd${fontconfig.subpixel.lcdfilter}
-
-
+ environment.etc.fonts.source =
+ let fontConf = pkgs.symlinkJoin {
+ name = "fontconfig-etc";
+ paths = cfg.confPkgs;
+ };
+ in "${fontConf}/etc/fonts/";
- ${optionalString (fontconfig.dpi != 0) ''
-
-
- ${toString fontconfig.dpi}
-
-
- ''}
-
-
- '';
- genericAliasConf = ''
-
-
-
-
-
- ${optionalString (fontconfig.defaultFonts.sansSerif != []) ''
-
- sans-serif
-
- ${concatStringsSep "\n"
- (map (font: "${font}")
- fontconfig.defaultFonts.sansSerif)}
-
-
- ''}
- ${optionalString (fontconfig.defaultFonts.serif != []) ''
-
- serif
-
- ${concatStringsSep "\n"
- (map (font: "${font}")
- fontconfig.defaultFonts.serif)}
-
-
- ''}
- ${optionalString (fontconfig.defaultFonts.monospace != []) ''
-
- monospace
-
- ${concatStringsSep "\n"
- (map (font: "${font}")
- fontconfig.defaultFonts.monospace)}
-
-
- ''}
-
-
- '';
- 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 ''
-
-
-
-
- ${concatStringsSep "\n" (map (font: "${font}") config.fonts.fonts)}
-
- ${cache pkgs.fontconfig}
- ${optionalString (pkgs.stdenv.isx86_64 && config.fonts.fontconfig.cache32Bit) ''
- ${cache pkgs.pkgsi686Linux.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 = ''
-
-
-
- fontconfig/conf.d
- fontconfig/fonts.conf
-
- '';
- };
-
- environment.systemPackages = [ pkgs.fontconfig ];
-
- };
+ environment.systemPackages = [ pkgs.fontconfig ];
+ };
}
diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix
index 6acf1ebce29c..f18ea5948f15 100644
--- a/pkgs/development/libraries/fontconfig/default.nix
+++ b/pkgs/development/libraries/fontconfig/default.nix
@@ -68,7 +68,6 @@ stdenv.mkDerivation rec {
cd "$out/etc/fonts"
rm conf.d/{50-user,51-local}.conf
"${libxslt.bin}/bin/xsltproc" --stringparam fontDirectories "${fontbhttf}" \
- --stringparam fontconfig "$out" \
--stringparam fontconfigConfigVersion "${configVersion}" \
--path $out/share/xml/fontconfig \
${./make-fonts-conf.xsl} $out/etc/fonts/fonts.conf \
diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl
index b59fcd0187b8..dddbbe9e516b 100644
--- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl
+++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl
@@ -28,8 +28,6 @@
/var/cache/fontconfig
-
- /etc/fonts/conf.d
/etc/fonts//conf.d