about summary refs log tree commit diff
path: root/modules/nixos/fonts.nix
blob: a333cb3a300d1c905284a67d01fd20d3fa348672 (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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.fonts;
in {
  config = mkMerge [
    (mkIf cfg.enable {
      nixfiles.modules.common.nix.allowedUnfreePackages = ["symbola"];
      hm.fonts.fontconfig.enable = true;
      fonts = {
        packages =
          cfg.packages
          ++ (with pkgs; [
            noto-fonts-emoji
            twitter-color-emoji
            symbola
          ]);

        fontconfig = {
          enable = true;

          defaultFonts = {
            emoji = mkForce [
              "Twitter Color Emoji"
              "Noto Color Emoji"
              "Symbola"
            ];
            monospace = mkForce [
              "Iosevka"
              "Sarasa Mono"
              "Source Han Mono"
              "Noto Sans Mono"
            ];
            sansSerif = mkForce [
              "Iosevka Aile"
              "Sarasa Gothic"
              "Source Han Sans"
              "Noto Sans"
            ];
            serif = mkForce [
              "Iosevka Etoile"
              "Sarasa Gothic"
              "Source Han Serif"
              "Noto Serif"
            ];
          };

          localConf = ''
            <?xml version='1.0'?>
            <!DOCTYPE fontconfig SYSTEM 'urn:fontconfig:fonts.dtd'>
            <fontconfig>
              <alias binding="same">
                <family>Helvetica</family>
                <prefer>
                  <family>sans-serif</family>
                </prefer>
              </alias>
              <alias binding="same">
                <family>Arial</family>
                <prefer>
                  <family>sans-serif</family>
                </prefer>
              </alias>
            </fontconfig>
          '';
        };
      };
    })
    (mkIf (!cfg.enable) {
      hm.fonts.fontconfig.enable = false;
      fonts.fontconfig.enable = false;
    })
  ];
}

Consider giving Nix/NixOS a try! <3