From e80e8b9dc95fd21de14bd4647cb957765030aa59 Mon Sep 17 00:00:00 2001 From: Eric Sagnes Date: Thu, 11 Aug 2016 08:45:43 +0900 Subject: [PATCH] fontconfig module: respect upstream definitions --- nixos/modules/config/fonts/fontconfig.nix | 63 +++++++++++-------- .../libraries/fontconfig/default.nix | 1 - 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/nixos/modules/config/fonts/fontconfig.nix b/nixos/modules/config/fonts/fontconfig.nix index 6494e09111d4..770c3a03f9d8 100644 --- a/nixos/modules/config/fonts/fontconfig.nix +++ b/nixos/modules/config/fonts/fontconfig.nix @@ -12,8 +12,6 @@ This module generates a package containing configuration files and link it in /e Fontconfig reads files in folder name / file name order, so the number prepended to the configuration file name decide the order of parsing. Low number means high priority. -Default fonts should have a high priority (low number) to be at the head of the preferred fonts list, fontconfig advise the 30~40 range. - */ { config, lib, pkgs, ... }: @@ -109,9 +107,13 @@ let cfg = config.fonts.fontconfig; ''; - # prefered default fonts configuration file - # priority 30 - genericAliasConf = + # local configuration file + # priority 51 + localConf = pkgs.writeText "fc-local.conf" cfg.localConf; + + # default fonts configuration file + # priority 52 + defaultFontsConf = let genDefault = fonts: name: optionalString (fonts != []) '' @@ -125,7 +127,7 @@ let cfg = config.fonts.fontconfig; ''; in - pkgs.writeText "fc-30-nixos-generic-alias.conf" '' + pkgs.writeText "fc-52-nixos-default-fonts.conf" '' @@ -140,17 +142,6 @@ let cfg = config.fonts.fontconfig; ''; - # user settings configuration file - # priority 99 - userConf = pkgs.writeText "fc-99-user.conf" '' - - - - fontconfig/conf.d - fontconfig/fonts.conf - - ''; - # fontconfig configuration package confPkg = pkgs.runCommand "fontconfig-conf" {} '' support_folder=$out/etc/fonts @@ -170,6 +161,13 @@ let cfg = config.fonts.fontconfig; ln -s ${latestPkg.out}/etc/fonts/conf.d/*.conf \ $latest_folder/conf.d/ + # update latest 51-local.conf path to look at the latest local.conf + rm $latest_folder/conf.d/51-local.conf + + substitute ${latestPkg.out}/etc/fonts/conf.d/51-local.conf \ + $latest_folder/conf.d/51-local.conf \ + --replace local.conf /etc/fonts/${latestVersion}/local.conf + # 00-nixos-cache.conf ln -s ${cacheConfSupport} \ $support_folder/conf.d/00-nixos-cache.conf @@ -179,15 +177,21 @@ let cfg = config.fonts.fontconfig; ln -s ${renderConf} $support_folder/conf.d/10-nixos-rendering.conf ln -s ${renderConf} $latest_folder/conf.d/10-nixos-rendering.conf - # 30-nixos-generic-alias.conf - ln -s ${genericAliasConf} $support_folder/conf.d/30-nixos-generic-alias.conf - ln -s ${genericAliasConf} $latest_folder/conf.d/30-nixos-generic-alias.conf - - # 99-user.conf - ${optionalString cfg.includeUserConf '' - ln -s ${userConf} $support_folder/conf.d/99-user.conf - ln -s ${userConf} $latest_folder/conf.d/99-user.conf + # 50-user.conf + ${optionalString (! cfg.includeUserConf) '' + rm $support_folder/conf.d/50-user.conf + rm $latest_folder/conf.d/50-user.conf ''} + + # local.conf (indirect priority 51) + ${optionalString (cfg.localConf != "") '' + ln -s ${localConf} $support_folder/local.conf + ln -s ${localConf} $latest_folder/local.conf + ''} + + # 52-nixos-default-fonts.conf + ln -s ${defaultFontsConf} $support_folder/conf.d/52-nixos-default-fonts.conf + ln -s ${defaultFontsConf} $latest_folder/conf.d/52-nixos-default-fonts.conf ''; # Package with configuration files @@ -241,6 +245,15 @@ in ''; }; + localConf = mkOption { + type = types.lines; + default = ""; + description = '' + System-wide customization file contents, has higher priority than + defaultFonts settings. + ''; + }; + defaultFonts = { monospace = mkOption { type = types.listOf types.str; diff --git a/pkgs/development/libraries/fontconfig/default.nix b/pkgs/development/libraries/fontconfig/default.nix index f18ea5948f15..74048afe731e 100644 --- a/pkgs/development/libraries/fontconfig/default.nix +++ b/pkgs/development/libraries/fontconfig/default.nix @@ -66,7 +66,6 @@ stdenv.mkDerivation rec { postInstall = '' cd "$out/etc/fonts" - rm conf.d/{50-user,51-local}.conf "${libxslt.bin}/bin/xsltproc" --stringparam fontDirectories "${fontbhttf}" \ --stringparam fontconfigConfigVersion "${configVersion}" \ --path $out/share/xml/fontconfig \