main
1{lib, ...}: {
2 den.aspects.desktop.style.fonts = {
3 settings = 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 sizes = {
19 applications = mkOption {
20 type = types.ints.positive;
21 default = 12;
22 };
23 desktop = mkOption {
24 type = types.ints.positive;
25 default = 12;
26 };
27 terminal = mkOption {
28 type = types.ints.positive;
29 default = 12;
30 };
31 };
32 serif = mkOption {
33 type = types.listOf fontType;
34 default = [
35 {
36 name = "Noto Serif CJK SC";
37 package = pkgs: pkgs.noto-fonts-cjk-serif;
38 }
39 ];
40 };
41 sansSerif = mkOption {
42 type = types.listOf fontType;
43 default = [
44 {
45 name = "Sarasa Gothic SC";
46 package = pkgs: pkgs.sarasa-gothic;
47 }
48 {
49 name = "Noto Sans CJK SC";
50 package = pkgs: pkgs.noto-fonts-cjk-sans;
51 }
52 ];
53 };
54 monospace = mkOption {
55 type = types.listOf fontType;
56 default = [
57 {
58 name = "Maple Mono NF CN";
59 package = pkgs: pkgs.maple-mono.NF-CN;
60 }
61 ];
62 };
63 emoji = mkOption {
64 type = types.listOf fontType;
65 default = [
66 {
67 name = "Noto Color Emoji";
68 package = pkgs: pkgs.noto-fonts-color-emoji;
69 }
70 ];
71 };
72 };
73
74 nixos = {
75 host,
76 pkgs,
77 ...
78 }: let
79 cfg = host.settings.desktop.style.fonts;
80 in {
81 fonts = {
82 enableDefaultPackages = false;
83 fontDir.enable = true;
84
85 packages =
86 (map (x: x.package pkgs)
87 (lib.concatMap (x: cfg.${x}) ["serif" "sansSerif" "monospace" "emoji"]))
88 ++ (with pkgs; [
89 dejavu_fonts
90 noto-fonts-lgc-plus
91 ]);
92 fontconfig.defaultFonts =
93 lib.genAttrs ["serif" "sansSerif" "monospace" "emoji"]
94 (x: lib.unique (map (x: x.name) cfg.${x}));
95 };
96 };
97 };
98}