fontconfig: generate font cache files
Also deprecates the `fonts.fontconfig.enableProfileFonts` option. The configuration is now always generated if `fonts.fontconfig.enable` is set. Fixes #520
This commit is contained in:
parent
2f819d1647
commit
f18e2933d4
|
@ -6,36 +6,74 @@ let
|
|||
|
||||
cfg = config.fonts.fontconfig;
|
||||
|
||||
profileDirectory = config.home.profileDirectory;
|
||||
|
||||
in
|
||||
|
||||
{
|
||||
meta.maintainers = [ maintainers.rycee ];
|
||||
|
||||
imports = [
|
||||
(mkRenamedOptionModule
|
||||
[ "fonts" "fontconfig" "enableProfileFonts" ]
|
||||
[ "fonts" "fontconfig" "enable" ])
|
||||
];
|
||||
|
||||
options = {
|
||||
fonts.fontconfig = {
|
||||
enableProfileFonts = mkOption {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = ''
|
||||
Configure fontconfig to discover fonts installed through
|
||||
Whether to enable fontconfig configuration. This will, for
|
||||
example, allow fontconfig to discover fonts and
|
||||
configurations installed through
|
||||
<varname>home.packages</varname> and
|
||||
<command>nix-env</command>.
|
||||
</para><para>
|
||||
Note, this is only necessary on non-NixOS systems.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enableProfileFonts {
|
||||
xdg.configFile."fontconfig/conf.d/10-nix-profile-fonts.conf".text = ''
|
||||
config = mkIf cfg.enable {
|
||||
home.extraProfileCommands = ''
|
||||
export FONTCONFIG_FILE=$(pwd)/fonts.conf
|
||||
|
||||
cat > $FONTCONFIG_FILE << EOF
|
||||
<?xml version='1.0'?>
|
||||
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
||||
<fontconfig>
|
||||
<dir>${config.home.profileDirectory}/lib/X11/fonts</dir>
|
||||
<dir>${config.home.profileDirectory}/share/fonts</dir>
|
||||
<dir>$out/lib/X11/fonts</dir>
|
||||
<dir>$out/share/fonts</dir>
|
||||
<cachedir>$out/lib/fontconfig/cache</cachedir>
|
||||
</fontconfig>
|
||||
EOF
|
||||
|
||||
${getBin pkgs.fontconfig}/bin/fc-cache -f
|
||||
rm $out/lib/fontconfig/cache/CACHEDIR.TAG
|
||||
|
||||
unset FONTCONFIG_FILE
|
||||
'';
|
||||
|
||||
xdg.configFile = {
|
||||
"fontconfig/conf.d/10-hm-fonts.conf".text = ''
|
||||
<?xml version='1.0'?>
|
||||
|
||||
<!-- Generated by Home Manager. -->
|
||||
|
||||
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
|
||||
<fontconfig>
|
||||
<include ignore_missing="yes">${config.home.path}/etc/fonts/conf.d</include>
|
||||
<include ignore_missing="yes">${config.home.path}/etc/fonts/fonts.conf</include>
|
||||
|
||||
<dir>${config.home.path}/lib/X11/fonts</dir>
|
||||
<dir>${config.home.path}/share/fonts</dir>
|
||||
<dir>${profileDirectory}/lib/X11/fonts</dir>
|
||||
<dir>${profileDirectory}/share/fonts</dir>
|
||||
|
||||
<cachedir>${config.home.path}/lib/fontconfig/cache</cachedir>
|
||||
</fontconfig>
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue