From 89401d986c520d28bf4f0f57448b0e6f158c7172 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 13 Aug 2020 18:51:23 +0200 Subject: [PATCH 1/3] Revert "fontconfig: Only read versioned config dirs" This reverts commit edf2541f02c6b24ea791710d5cadeae36f9b1a3a. Turns out lot of software (including Chromium) use bundled fontconfig so we either need to wrap every one of those, or re-introduce the global unversioned config. The latter is easier but weakens hermetic configs. But perhaps those are not really worth the effort. Given that programs linked against fc 2.12.6 on fc 2.13.92 system seem to at least display text, even while printing tons of errors (as long as you generate fc cache manually), and same thing the other way around, hopefully it will not be an issue in the future. We give up on the hermetic configs in exchange for getting rid of lot of complexity. --- .../libraries/fontconfig/config-compat.patch | 28 +++++++------------ .../libraries/fontconfig/default.nix | 14 ++-------- .../libraries/fontconfig/make-fonts-conf.xsl | 3 -- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/pkgs/development/libraries/fontconfig/config-compat.patch b/pkgs/development/libraries/fontconfig/config-compat.patch index ddf7bc78180..e86f08fb553 100644 --- a/pkgs/development/libraries/fontconfig/config-compat.patch +++ b/pkgs/development/libraries/fontconfig/config-compat.patch @@ -1,22 +1,17 @@ -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 +commit 05c6adf8104b4321d3a3716a7b9feb6bf223ed0c (HEAD, nixpkgs) +Author: Vladimír Čunát +Date: Tue Nov 4 12:24:25 2014 +0100 -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(-) + 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. diff --git a/src/fccfg.c b/src/fccfg.c -index 342c996..98a1324 100644 +index 6377fd7..e9eb10a 100644 --- a/src/fccfg.c +++ b/src/fccfg.c -@@ -2391,8 +2391,13 @@ FcConfigGetFilename (FcConfig *config, +@@ -2070,8 +2070,13 @@ FcConfigFilename (const FcChar8 *url) if (!url || !*url) { url = (FcChar8 *) getenv ("FONTCONFIG_FILE"); @@ -27,10 +22,7 @@ index 342c996..98a1324 100644 + } if (!url) - url = (FcChar8 *) FONTCONFIG_FILE; -+ url = (FcChar8 *) FONTCONFIG_PATH "/" FONTCONFIG_FILE; ++ url = (FcChar8 *) "/etc/fonts/fonts.conf"; } file = 0; --- -2.26.2 - diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index 29d9e3289c1..ab7340be559 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -13,10 +13,9 @@ /** Font configuration scheme - ./config-compat.patch makes fontconfig try the following root configs, in order: - $FONTCONFIG_FILE, /etc/fonts/${configVersion}/fonts.conf, ${fontconfig.out}/etc/fonts/fonts.conf + $FONTCONFIG_FILE, /etc/fonts/${configVersion}/fonts.conf, /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 NixOS, - falling back to upstream defaults on non-NixOS. + and still use *global* font configuration at both NixOS or 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. @@ -112,20 +111,11 @@ 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 6ec2e7ab515..74abb9cffaf 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -31,9 +31,6 @@ /etc/fonts//conf.d - - /etc/fonts/conf.d - fonts From b49a7699701223b804bdbeb9799b7debec695e87 Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 13 Aug 2020 20:04:10 +0200 Subject: [PATCH 2/3] fontconfig: get rid of rest of versioned configs The incompatibility does not seem to exist any more: programs linked against fc 2.12 on fc 2.14 system seem to at least display text, even while printing tons of errors (as long as you generate fc cache manually), and same thing the other way around. Hopefully it will not be an issue in the future. --- nixos/modules/config/fonts/fontconfig.nix | 9 +++-- .../libraries/fontconfig/config-compat.patch | 28 ------------- .../libraries/fontconfig/default.nix | 40 +++++++------------ .../libraries/fontconfig/make-fonts-conf.nix | 1 - .../libraries/fontconfig/make-fonts-conf.xsl | 5 +-- 5 files changed, 21 insertions(+), 62 deletions(-) delete mode 100644 pkgs/development/libraries/fontconfig/config-compat.patch diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 1f1044bc5af..2e8c4624414 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -1,6 +1,6 @@ /* -Configuration files are linked to /etc/fonts/${pkgs.fontconfig.configVersion}/conf.d/ +Configuration files are linked to /etc/fonts/conf.d/ This module generates a package containing configuration files and link it in /etc/fonts. @@ -176,15 +176,16 @@ let confPkg = pkgs.runCommand "fontconfig-conf" { preferLocalBuild = true; } '' - dst=$out/etc/fonts/${pkg.configVersion}/conf.d + dst=$out/etc/fonts/conf.d mkdir -p $dst # fonts.conf ln -s ${pkg.out}/etc/fonts/fonts.conf \ $dst/../fonts.conf # TODO: remove this legacy symlink once people stop using packages built before #95358 was merged - ln -s /etc/fonts/${pkg.configVersion}/fonts.conf \ - $out/etc/fonts/fonts.conf + mkdir -p $out/etc/fonts/2.11 + ln -s /etc/fonts/fonts.conf \ + $out/etc/fonts/2.11/fonts.conf # fontconfig default config files ln -s ${pkg.out}/etc/fonts/conf.d/*.conf \ diff --git a/pkgs/development/libraries/fontconfig/config-compat.patch b/pkgs/development/libraries/fontconfig/config-compat.patch deleted file mode 100644 index e86f08fb553..00000000000 --- a/pkgs/development/libraries/fontconfig/config-compat.patch +++ /dev/null @@ -1,28 +0,0 @@ -commit 05c6adf8104b4321d3a3716a7b9feb6bf223ed0c (HEAD, nixpkgs) -Author: Vladimír Čunát -Date: Tue Nov 4 12:24:25 2014 +0100 - - 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. - -diff --git a/src/fccfg.c b/src/fccfg.c -index 6377fd7..e9eb10a 100644 ---- a/src/fccfg.c -+++ b/src/fccfg.c -@@ -2070,8 +2070,13 @@ FcConfigFilename (const FcChar8 *url) - if (!url || !*url) - { - url = (FcChar8 *) getenv ("FONTCONFIG_FILE"); -+ if (!url) { -+ static const FcChar8 *cfPath = "/etc/fonts/@configVersion@/fonts.conf"; -+ if (access (cfPath, R_OK) == 0) -+ url = cfPath; -+ } - if (!url) -- url = (FcChar8 *) FONTCONFIG_FILE; -+ url = (FcChar8 *) "/etc/fonts/fonts.conf"; - } - file = 0; - diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index ab7340be559..72df121200e 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -11,20 +11,6 @@ , autoreconfHook }: -/** 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 - 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. - - 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. - -*/ - -let - configVersion = "2.11"; # bump whenever fontconfig breaks compatibility with older configurations -in stdenv.mkDerivation rec { pname = "fontconfig"; version = "2.13.92"; @@ -35,11 +21,6 @@ stdenv.mkDerivation rec { }; patches = [ - (substituteAll { - src = ./config-compat.patch; - 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 { @@ -72,6 +53,13 @@ stdenv.mkDerivation rec { url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/37c7c748740bf6f2468d59e67951902710240b34.patch"; sha256 = "1rz5zrfwhpn9g49wrzzrmdglj78pbvpnw8ksgsw6bxq8l5d84jfr"; }) + + # Show warning instead of error when encountering unknown attribute in config. + # https://gitlab.freedesktop.org/fontconfig/fontconfig/merge_requests/111 + (fetchpatch { + url = "https://gitlab.freedesktop.org/fontconfig/fontconfig/commit/409b37c62780728755c908991c912a6b16f2389c.patch"; + sha256 = "zJFh37QErSAINPGFkFVJyhYRP27BuIN7PIgoDl/PIwI="; + }) ]; outputs = [ "bin" "dev" "lib" "out" ]; # $out contains all the config @@ -92,6 +80,7 @@ stdenv.mkDerivation rec { ]; configureFlags = [ + "--sysconfdir=/etc" "--with-arch=${stdenv.hostPlatform.parsed.cpu.name}" "--with-cache-dir=/var/cache/fontconfig" # otherwise the fallback is in $out/ "--disable-docs" @@ -105,23 +94,22 @@ stdenv.mkDerivation rec { doCheck = true; - # Don't try to write to /var/cache/fontconfig at install time. - installFlags = [ "fc_cachedir=$(TMPDIR)/dummy" "RUN_FC_CACHE_TEST=false" ]; + installFlags = [ + # Don't try to write to /var/cache/fontconfig at install time. + "fc_cachedir=$(TMPDIR)/dummy" + "RUN_FC_CACHE_TEST=false" + "sysconfdir=${placeholder "out"}/etc" + ]; postInstall = '' cd "$out/etc/fonts" xsltproc --stringparam fontDirectories "${dejavu_fonts.minimal}" \ - --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 ''; - passthru = { - inherit configVersion; - }; - meta = with stdenv.lib; { description = "A library for font customization and configuration"; homepage = "http://fontconfig.org/"; diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.nix b/pkgs/development/libraries/fontconfig/make-fonts-conf.nix index b18d72e0a22..2f82c5032ab 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.nix +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.nix @@ -10,7 +10,6 @@ runCommand "fonts.conf" '' xsltproc --stringparam fontDirectories "$fontDirectories" \ --stringparam fontconfig "${fontconfig.out}" \ - --stringparam fontconfigConfigVersion "${fontconfig.configVersion}" \ --path ${fontconfig.out}/share/xml/fontconfig \ ${./make-fonts-conf.xsl} ${fontconfig.out}/etc/fonts/fonts.conf \ > $out diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl index 74abb9cffaf..4edccfb79e1 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -16,7 +16,6 @@ - @@ -28,8 +27,8 @@ /var/cache/fontconfig - - /etc/fonts//conf.d + + /etc/fonts/conf.d fonts From 6f9606380419fe1b4e1c91b48982ed58040eacdd Mon Sep 17 00:00:00 2001 From: Jan Tojnar Date: Thu, 3 Sep 2020 09:42:58 +0200 Subject: [PATCH 3/3] makeFontsConf: clean up The use of the argument was removed in 2016 but its definition was left behind. https://github.com/NixOS/nixpkgs/commit/cd2948a72e3116a3a42f1f523fe2638db994362c --- pkgs/development/libraries/fontconfig/make-fonts-conf.nix | 1 - pkgs/development/libraries/fontconfig/make-fonts-conf.xsl | 1 - 2 files changed, 2 deletions(-) diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.nix b/pkgs/development/libraries/fontconfig/make-fonts-conf.nix index 2f82c5032ab..493f662d0ce 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.nix +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.nix @@ -9,7 +9,6 @@ runCommand "fonts.conf" } '' xsltproc --stringparam fontDirectories "$fontDirectories" \ - --stringparam fontconfig "${fontconfig.out}" \ --path ${fontconfig.out}/share/xml/fontconfig \ ${./make-fonts-conf.xsl} ${fontconfig.out}/etc/fonts/fonts.conf \ > $out diff --git a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl index 4edccfb79e1..f937954ca9b 100644 --- a/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl +++ b/pkgs/development/libraries/fontconfig/make-fonts-conf.xsl @@ -15,7 +15,6 @@ -