From 27b14ee82a6443462349f1ef908d860576c210f6 Mon Sep 17 00:00:00 2001 From: worldofpeace Date: Tue, 19 Nov 2019 20:45:30 -0500 Subject: [PATCH 1/5] fontconfig: 2.12.6 -> 2.13.92 --- .../libraries/fontconfig/default.nix | 56 ++++++++++++++++--- .../libraries/fontconfig/fix-joypixels.patch | 23 -------- 2 files changed, 47 insertions(+), 32 deletions(-) delete mode 100644 pkgs/development/libraries/fontconfig/fix-joypixels.patch diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index 0518cb257ab..37f88a770fc 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -1,5 +1,14 @@ -{ stdenv, substituteAll, fetchurl -, pkgconfig, freetype, expat, libxslt, gperf, dejavu_fonts +{ stdenv +, fetchpatch +, substituteAll +, fetchurl +, pkg-config +, freetype +, expat +, libxslt +, gperf +, dejavu_fonts +, autoreconfHook }: /** Font configuration scheme @@ -18,11 +27,11 @@ let in stdenv.mkDerivation rec { pname = "fontconfig"; - version = "2.12.6"; + version = "2.13.92"; src = fetchurl { - url = "http://fontconfig.org/release/${pname}-${version}.tar.bz2"; - sha256 = "05zh65zni11kgnhg726gjbrd55swspdvhqbcnj5a5xh8gn03036g"; + url = "http://fontconfig.org/release/${pname}-${version}.tar.xz"; + sha256 = "0kkfsvxcvcphm9zcgsh646gix3qn4spz555wa1jp5hbq70l62vjh"; }; patches = [ @@ -31,15 +40,44 @@ stdenv.mkDerivation rec { inherit configVersion; }) + # Fix fonts not being loaded when missing included configs that have ignore_missing="yes". + # https://bugzilla.redhat.com/show_bug.cgi?id=1744377 + (fetchpatch { + url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/fcada522913e5e07efa6367eff87ace9f06d24c8.patch"; + sha256 = "1jbm3vw45b3qjnqrh2545v1k8vmb29c09v2wj07jnrq3lnchbvmn"; + }) + + # Register JoyPixels as an emoji font. # https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/67 - ./fix-joypixels.patch + (fetchpatch { + url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/65087ac7ce4cc5f2109967c1380b474955dcb590.patch"; + sha256 = "1dkrbqx1c1d8yfnx0igvv516wanw2ksrpm3fbpm2h9nw0hccwqvm"; + }) + + # Fix invalid DTD in reset-dirs. + # https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/78 + (fetchpatch { + url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/a4aa66a858f1ecd375c5efe5916398281f73f794.patch"; + sha256 = "1j4ky8jhpllfm1lh2if34xglh2hl79nsa0xxgzxpj9sx6h4v99j5"; + }) ]; outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config - propagatedBuildInputs = [ freetype ]; - nativeBuildInputs = [ pkgconfig gperf libxslt ]; - buildInputs = [ expat ]; + nativeBuildInputs = [ + gperf + libxslt + pkg-config + autoreconfHook + ]; + + buildInputs = [ + expat + ]; + + propagatedBuildInputs = [ + freetype + ]; configureFlags = [ "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" diff --git a/pkgs/development/libraries/fontconfig/fix-joypixels.patch b/pkgs/development/libraries/fontconfig/fix-joypixels.patch deleted file mode 100644 index d5654063fe8..00000000000 --- a/pkgs/development/libraries/fontconfig/fix-joypixels.patch +++ /dev/null @@ -1,23 +0,0 @@ ---- a/conf.d/45-generic.conf -+++ b/conf.d/45-generic.conf -@@ -5,6 +5,10 @@ - - - -+ -+ JoyPixels -+ emoji -+ - - Emoji Two - emoji ---- a/conf.d/60-generic.conf -+++ b/conf.d/60-generic.conf -@@ -29,6 +29,7 @@ - - emoji - -+ JoyPixels - Emoji Two - Emoji One - From 87786bc47f70646fefcbb1dbafd7d7326b97fc7b Mon Sep 17 00:00:00 2001 From: worldofpeace Date: Fri, 22 Nov 2019 16:35:27 -0500 Subject: [PATCH 2/5] fontconfig: bump configVersion to 2.13 --- pkgs/development/libraries/fontconfig/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index 37f88a770fc..b1bcf74fed4 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -23,7 +23,7 @@ */ let - configVersion = "2.11"; # bump whenever fontconfig breaks compatibility with older configurations + configVersion = "2.13"; # bump whenever fontconfig breaks compatibility with older configurations in stdenv.mkDerivation rec { pname = "fontconfig"; From edf2541f02c6b24ea791710d5cadeae36f9b1a3a Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 27 May 2020 04:35:25 +0200 Subject: [PATCH 3/5] fontconfig: Only read versioned config dirs Falling back to unversioned `/etc/fonts/conf.d` when versioned one does not exist is problematic since it only occurs on non-NixOS systems and those are likely to have a different version of fontconfig. When those versions use incompatible elements in the config, apps using fontconfig will crash. Instead, we are now falling back to the in-package `fonts.conf` file that loads both the versioned global `conf.d` directory and the in-package `conf.d` since using upstream settings on non-NixOS is preferable to not being able to use apps there. In fact, we would not even need to link `fonts.conf`, as the in-package `fonts.conf` will be always used unless someone creates the global one manually (the option is still retained if one wants to write a custom NixOS module and to avoid unnecessary stat call on NixOS). Additionally, since the `fonts.conf` will always load `conf.d` from the package, we no longer need to install them to sytem `/etc` in the module. This needed some mucking with `50-user.conf` which disables configs in user directories (a good thing IMO, NixOS module will turn it back on) but otherwise, it is cleaner. The files are still prioritized by their name, regardless of their location. See https://github.com/NixOS/nixpkgs/pull/73795#issuecomment-634370125 for more information. --- nixos/modules/config/fonts/fontconfig.nix | 16 ++++------- .../libraries/fontconfig/config-compat.patch | 28 ++++++++++++------- .../libraries/fontconfig/default.nix | 14 ++++++++-- .../libraries/fontconfig/make-fonts-conf.xsl | 3 ++ 4 files changed, 39 insertions(+), 22 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index ac2a024eaa8..52d284f739b 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 e86f08fb553..ddf7bc78180 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 b1bcf74fed4..f24518f546a 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 dddbbe9e516..199cd1fd9e9 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 From 993deed7ab862c9657302e9ba7dd5169b6178729 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Mon, 15 Jun 2020 14:12:47 +0200 Subject: [PATCH 4/5] fontconfig: Load fonts also from FHS paths With previous patch, we no longer load non-versioned fonts.conf file to avoid incompatibilities but this also means fontconfig will not load system-wide installed fonts on non-NixOS systems. As a compromise, let's hardcode the FHS font paths to the built-in config so that the system fonts work there. Unlike with the system config we do not need to worry about compatibility as incompatible font files will be simply ignored. Of course there will still be disparity if the system install fonts to some other location than these two but I am afraid this is the best we can do. See https://github.com/NixOS/nixpkgs/pull/73795#issuecomment-635771967 for discussion. --- pkgs/development/libraries/fontconfig/make-fonts-conf.xsl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl index 199cd1fd9e9..6ec2e7ab515 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -43,6 +43,11 @@ ~/.nix-profile/lib/X11/fonts ~/.nix-profile/share/fonts + + + /usr/share/fonts + /usr/local/share/fonts + /nix/var/nix/profiles/default/lib/X11/fonts /nix/var/nix/profiles/default/share/fonts From 6f8345035bf07e4271fdf896d04e27f46a7e6e84 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Wed, 24 Jun 2020 01:01:35 +0200 Subject: [PATCH 5/5] fontconfig: remove its rules from configs ITS rules are used for extracting translatable strings and they have been moved to external files in 2.13.92 so they are not needed in the config files themselves. Removing them also cuts down on errors/warnings produced when using older versions of fontconfig (< 2.12.92). Now it will only complain about the description element but that is fortunately just a warning, not errors like the ones caused by the its attributes. Thanks to this, we can change the config version in NixOS module back to 2.11 allowing us to re-use the 2.13/2.14 configs for apps built against 2.12 fontconfig. --- pkgs/development/libraries/fontconfig/default.nix | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index f24518f546a..29d9e3289c1 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -24,7 +24,7 @@ */ let - configVersion = "2.13"; # bump whenever fontconfig breaks compatibility with older configurations + configVersion = "2.11"; # bump whenever fontconfig breaks compatibility with older configurations in stdenv.mkDerivation rec { pname = "fontconfig"; @@ -61,6 +61,18 @@ stdenv.mkDerivation rec { url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/a4aa66a858f1ecd375c5efe5916398281f73f794.patch"; sha256 = "1j4ky8jhpllfm1lh2if34xglh2hl79nsa0xxgzxpj9sx6h4v99j5"; }) + + # Do not include its tags, they are external now and only cause warnings with old fontconfig clients. + # https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/97 + (fetchpatch { + url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/528b17b2837c3b102acd90cc7548d07bacaccb1f.patch"; + sha256 = "1zf4wcd2xlprh805jalfy8ja5c2qzgkh4fwd1m9d638nl9gx932m"; + }) + # https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/100 + (fetchpatch { + url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/37c7c748740bf6f2468d59e67951902710240b34.patch"; + sha256 = "1rz5zrfwhpn9g49wrzzrmdglj78pbvpnw8ksgsw6bxq8l5d84jfr"; + }) ]; outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config