1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-16 08:09:45 +01:00
home-manager/modules/misc/fontconfig.nix

80 lines
2 KiB
Nix
Raw Normal View History

2017-10-09 18:37:57 +02:00
{ config, lib, pkgs, ... }:
with lib;
let
cfg = config.fonts.fontconfig;
profileDirectory = config.home.profileDirectory;
2017-10-09 18:37:57 +02:00
in
{
meta.maintainers = [ maintainers.rycee ];
imports = [
(mkRenamedOptionModule
[ "fonts" "fontconfig" "enableProfileFonts" ]
[ "fonts" "fontconfig" "enable" ])
];
2017-10-09 18:37:57 +02:00
options = {
fonts.fontconfig = {
enable = mkOption {
2017-10-09 18:37:57 +02:00
type = types.bool;
default = false;
description = ''
Whether to enable fontconfig configuration. This will, for
example, allow fontconfig to discover fonts and
configurations installed through
2017-10-09 18:37:57 +02:00
<varname>home.packages</varname> and
<command>nix-env</command>.
'';
};
};
};
config = mkIf cfg.enable {
home.extraProfileCommands = ''
export FONTCONFIG_FILE=$(pwd)/fonts.conf
cat > $FONTCONFIG_FILE << EOF
2017-10-09 18:37:57 +02:00
<?xml version='1.0'?>
<!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
<fontconfig>
<dir>$out/lib/X11/fonts</dir>
<dir>$out/share/fonts</dir>
<cachedir>$out/lib/fontconfig/cache</cachedir>
2017-10-09 18:37:57 +02:00
</fontconfig>
EOF
${getBin pkgs.fontconfig}/bin/fc-cache -f
rm $out/lib/fontconfig/cache/CACHEDIR.TAG
unset FONTCONFIG_FILE
2017-10-09 18:37:57 +02:00
'';
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>
'';
};
2017-10-09 18:37:57 +02:00
};
}