main
1{lib, ...}: {
2 den.aspects.desktop.aesthetic.fonts = {
3 settings.host = let
4 inherit (lib) mkOption types;
5
6 fontType = types.submodule {
7 options = {
8 name = mkOption {
9 type = types.str;
10 };
11 package = mkOption {
12 type = types.functionTo types.package;
13 example = lib.literalExpression "pkgs: pkgs.dejavu_fonts";
14 };
15 };
16 };
17 in {
18 size = mkOption {
19 type = types.ints.positive;
20 default = 12;
21 };
22 serif = mkOption {
23 type = types.listOf fontType;
24 default = [
25 {
26 name = "Source Han Serif SC VF";
27 package = pkgs: pkgs.source-han-serif-vf-ttf;
28 }
29 {
30 name = "Noto Serif CJK SC";
31 package = pkgs: pkgs.noto-fonts-cjk-serif;
32 }
33 {
34 name = "Symbols Nerd Font";
35 package = pkgs: pkgs.nerd-fonts.symbols-only;
36 }
37 ];
38 };
39 sansSerif = mkOption {
40 type = types.listOf fontType;
41 default = [
42 {
43 name = "Sarasa Gothic SC";
44 package = pkgs: pkgs.sarasa-gothic;
45 }
46 {
47 name = "Source Han Sans SC VF";
48 package = pkgs: pkgs.source-han-sans-vf-ttf;
49 }
50 {
51 name = "Noto Sans CJK SC";
52 package = pkgs: pkgs.noto-fonts-cjk-sans;
53 }
54 {
55 name = "Symbols Nerd Font";
56 package = pkgs: pkgs.nerd-fonts.symbols-only;
57 }
58 ];
59 };
60 monospace = mkOption {
61 type = types.listOf fontType;
62 default = [
63 {
64 name = "JetBrains Mono";
65 package = pkgs: pkgs.jetbrains-mono;
66 }
67 {
68 name = "Maple Mono NF CN";
69 package = pkgs: pkgs.maple-mono.NF-CN;
70 }
71 ];
72 };
73 emoji = mkOption {
74 type = types.listOf fontType;
75 default = [
76 {
77 name = "Twitter Color Emoji";
78 package = pkgs: pkgs.twitter-color-emoji;
79 }
80 {
81 name = "Noto Color Emoji";
82 package = pkgs: pkgs.noto-fonts-color-emoji;
83 }
84 {
85 name = "Symbols Nerd Font";
86 package = pkgs: pkgs.nerd-fonts.symbols-only;
87 }
88 ];
89 };
90 };
91
92 nixos = {
93 host,
94 pkgs,
95 ...
96 }: let
97 cfg = host.settings.desktop.aesthetic.fonts;
98 in {
99 fonts = {
100 enableDefaultPackages = false;
101 fontDir.enable = true;
102
103 packages = lib.unique ((map (x: x.package pkgs)
104 (lib.concatMap (x: cfg.${x}) ["serif" "sansSerif" "monospace" "emoji"]))
105 ++ (with pkgs; [
106 # CJK
107 arphic-ukai
108 lxgw-wenkai
109 lxgw-neoxihei
110 nur.repos.hpcesia.lxgw-neozhisong
111 nur.repos.hpcesia.zhuque-fangsong
112
113 # Latn
114 dejavu_fonts
115 gyre-fonts
116 inter
117 noto-fonts-lgc-plus
118
119 # Math
120 stix-two
121 tex-gyre-math.termes
122
123 # Misc
124 unifont
125 unifont_upper
126 ]));
127
128 fontconfig = {
129 antialias = true;
130 hinting = {
131 enable = false;
132 style = "none";
133 };
134
135 defaultFonts =
136 lib.genAttrs ["serif" "sansSerif" "monospace" "emoji"]
137 (x: lib.unique (map (x: x.name) cfg.${x}));
138
139 localConf = builtins.readFile ./fonts.local.xml;
140 };
141 };
142 };
143
144 hjem = {
145 xdg.data.files."fonts" = {
146 type = "symlink";
147 source = "/run/current-system/sw/share/X11/fonts";
148 };
149 };
150 };
151}