summary refs log tree commit diff
path: root/nixos/modules/config/fonts/fontconfig.nix
blob: cf70ca264d6aa64f566e920650253064d169bbb1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{ config, lib, pkgs, ... }:

with lib;

{

  options = {

    fonts = {

      enableFontConfig = mkOption { # !!! should be enableFontconfig
        type = types.bool;
        default = true;
        description = ''
          If enabled, a Fontconfig configuration file will be built
          pointing to a set of default fonts.  If you don't care about
          running X11 applications or any other program that uses
          Fontconfig, you can turn this option off and prevent a
          dependency on all those fonts.
        '';
      };

    };

  };


  config = mkIf config.fonts.enableFontConfig {

    # Bring in the default (upstream) fontconfig configuration.
    environment.etc."fonts/fonts.conf".source =
      pkgs.makeFontsConf { fontDirectories = config.fonts.fonts; };

    environment.etc."fonts/conf.d/00-nixos.conf".text =
      ''
        <?xml version='1.0'?>
        <!DOCTYPE fontconfig SYSTEM 'fonts.dtd'>
        <fontconfig>

          <!-- Set the default hinting style to "slight". -->
          <match target="font">
            <edit mode="assign" name="hintstyle">
              <const>hintslight</const>
            </edit>
          </match>

        </fontconfig>
      '';

    # FIXME: This variable is no longer needed, but we'll keep it
    # around for a while for applications linked against old
    # fontconfig builds.
    environment.variables.FONTCONFIG_FILE = "/etc/fonts/fonts.conf";

    environment.systemPackages = [ pkgs.fontconfig ];

  };

}