diff --git a/modules/misc/fontconfig.nix b/modules/misc/fontconfig.nix
index 9ad8b195f..2b989c8fc 100644
--- a/modules/misc/fontconfig.nix
+++ b/modules/misc/fontconfig.nix
@@ -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
home.packages and
nix-env.
-
- 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
- ${config.home.profileDirectory}/lib/X11/fonts
- ${config.home.profileDirectory}/share/fonts
+ $out/lib/X11/fonts
+ $out/share/fonts
+ $out/lib/fontconfig/cache
+ 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 = ''
+
+
+
+
+
+
+ ${config.home.path}/etc/fonts/conf.d
+ ${config.home.path}/etc/fonts/fonts.conf
+
+ ${config.home.path}/lib/X11/fonts
+ ${config.home.path}/share/fonts
+ ${profileDirectory}/lib/X11/fonts
+ ${profileDirectory}/share/fonts
+
+ ${config.home.path}/lib/fontconfig/cache
+
+ '';
+ };
};
}