diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index ac2a024eaa89430..52d284f739b3cea 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -214,15 +214,7 @@ let # fontconfig default config files ln -s ${supportPkg.out}/etc/fonts/conf.d/*.conf \ $support_folder/ - ln -s ${latestPkg.out}/etc/fonts/conf.d/*.conf \ - $latest_folder/ - - # update latest 51-local.conf path to look at the latest local.conf - rm $latest_folder/51-local.conf - - substitute ${latestPkg.out}/etc/fonts/conf.d/51-local.conf \ - $latest_folder/51-local.conf \ - --replace local.conf /etc/fonts/${latestVersion}/local.conf + # Latest fontconfig is configured to look for the upstream defaults inside the package. # 00-nixos-cache.conf ln -s ${cacheConfSupport} \ @@ -236,7 +228,11 @@ let # 50-user.conf ${optionalString (!cfg.includeUserConf) '' rm $support_folder/50-user.conf - rm $latest_folder/50-user.conf + ''} + # Since latest fontconfig looks for default files inside the package, + # we had to move this one elsewhere to be able to exclude it here. + ${optionalString cfg.includeUserConf '' + ln -s ${latestPkg.out}/etc/fonts/conf.d.bak/50-user.conf $latest_folder/50-user.conf ''} # local.conf (indirect priority 51) diff --git a/pkgs/development/libraries/fontconfig/config-compat.patch b/pkgs/development/libraries/fontconfig/config-compat.patch index e86f08fb553c9f9..ddf7bc78180ca9a 100644 --- a/pkgs/development/libraries/fontconfig/config-compat.patch +++ b/pkgs/development/libraries/fontconfig/config-compat.patch @@ -1,17 +1,22 @@ -commit 05c6adf8104b4321d3a3716a7b9feb6bf223ed0c (HEAD, nixpkgs) -Author: Vladimír Čunát -Date: Tue Nov 4 12:24:25 2014 +0100 +From 2ff9b53ce755be183ef9274f7dd3f9ac537173f6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= +Date: Tue, 4 Nov 2014 12:24:25 +0100 +Subject: [PATCH] add check for /etc/fonts/@configVersion@/fonts.conf - add check for /etc/fonts/@configVersion@/fonts.conf - - It's checked between FONTCONFIG_FILE and the usual /etc/fonts/fonts.conf. - Also, hardcode /etc/fonts/fonts.conf to prevent accidental override. +It's checked between FONTCONFIG_FILE and the in-package etc/fonts/fonts.conf. +The latter is used so that on non-NixOS distributions, fontconfig works at least +with upstream defaults, even when the global config is incompatible. + +Co-Authored-By: Jan Tojnar +--- + src/fccfg.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/fccfg.c b/src/fccfg.c -index 6377fd7..e9eb10a 100644 +index 342c996..98a1324 100644 --- a/src/fccfg.c +++ b/src/fccfg.c -@@ -2070,8 +2070,13 @@ FcConfigFilename (const FcChar8 *url) +@@ -2391,8 +2391,13 @@ FcConfigGetFilename (FcConfig *config, if (!url || !*url) { url = (FcChar8 *) getenv ("FONTCONFIG_FILE"); @@ -22,7 +27,10 @@ index 6377fd7..e9eb10a 100644 + } if (!url) - url = (FcChar8 *) FONTCONFIG_FILE; -+ url = (FcChar8 *) "/etc/fonts/fonts.conf"; ++ url = (FcChar8 *) FONTCONFIG_PATH "/" FONTCONFIG_FILE; } file = 0; +-- +2.26.2 + diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index b1bcf74fed466e6..f24518f546a25e6 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -13,9 +13,10 @@ /** Font configuration scheme - ./config-compat.patch makes fontconfig try the following root configs, in order: - $FONTCONFIG_FILE, /etc/fonts/${configVersion}/fonts.conf, /etc/fonts/fonts.conf + $FONTCONFIG_FILE, /etc/fonts/${configVersion}/fonts.conf, ${fontconfig.out}/etc/fonts/fonts.conf This is done not to override config of pre-2.11 versions (which just blow up) - and still use *global* font configuration at both NixOS or non-NixOS. + and still use *global* font configuration at NixOS, + falling back to upstream defaults on non-NixOS. - NixOS creates /etc/fonts/${configVersion}/fonts.conf link to $out/etc/fonts/fonts.conf, and other modifications should go to /etc/fonts/${configVersion}/conf.d - See ./make-fonts-conf.xsl for config details. @@ -99,11 +100,20 @@ stdenv.mkDerivation rec { postInstall = '' cd "$out/etc/fonts" xsltproc --stringparam fontDirectories "${dejavu_fonts.minimal}" \ + --stringparam fontconfig "$out" \ --stringparam fontconfigConfigVersion "${configVersion}" \ --path $out/share/xml/fontconfig \ ${./make-fonts-conf.xsl} $out/etc/fonts/fonts.conf \ > fonts.conf.tmp mv fonts.conf.tmp $out/etc/fonts/fonts.conf + + # Make it easier to remove user config in NixOS module. + mkdir -p $out/etc/fonts/conf.d.bak + mv $out/etc/fonts/conf.d/50-user.conf $out/etc/fonts/conf.d.bak + + # update latest 51-local.conf path to look at the latest local.conf + substituteInPlace $out/etc/fonts/conf.d/51-local.conf \ + --replace local.conf /etc/fonts/${configVersion}/local.conf ''; passthru = { diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl index dddbbe9e516bfc6..199cd1fd9e918b3 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -31,6 +31,9 @@ /etc/fonts//conf.d + + /etc/fonts/conf.d + fonts