about summary refs log tree commit diff
path: root/modules/common/stylix.nix
blob: f17cb4c212b5dd585fc705620e2112ccd18dbf90 (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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{
  config,
  inputs,
  lib,
  pkgs,
  this,
  ...
}:
with lib;
{
  imports = [
    inputs.stylix.nixosModules.stylix
    (mkAliasOptionModule
      [ "colors" ]
      [
        "lib"
        "stylix"
        "colors"
      ]
    )
  ];

  options.nixfiles.modules.common.stylix.fonts.extraPackages = mkOption {
    description = "Font packages.";
    default = with pkgs; [
      font-awesome
      noto-fonts
      noto-fonts-emoji
      sarasa-gothic
      source-han-mono
      source-han-sans
      source-han-serif
    ];
    readOnly = true;
  };

  # Styling and color binding can be sourced from here[1].
  #
  # [1]: https://github.com/tinted-theming/base24/blob/master/styling.md
  config = {
    stylix = {
      enable = this.isHeadful;
      autoEnable = this.isHeadful;

      image = pkgs.fetchurl {
        url = "https://upload.wikimedia.org/wikipedia/commons/a/a5/Bonaparte_ante_la_Esfinge%2C_por_Jean-Léon_Gérôme.jpg";
        hash = "sha256-qWv52oT8cF9K4ZoeawmR3jgoGB2ARfjbKKc12IljUcM=";
      };

      base16Scheme = "${pkgs.base16-schemes}/share/themes/tomorrow.yaml";

      fonts = {
        monospace = {
          package = pkgs.iosevka;
          name = "Iosevka";
        };

        serif = {
          package = pkgs.iosevka-bin.override { variant = "Etoile"; };
          name = "Iosevka Etoile";
        };

        sansSerif = {
          package = pkgs.iosevka-bin.override { variant = "Aile"; };
          name = "Iosevka Aile";
        };

        emoji = {
          package = pkgs.twitter-color-emoji;
          name = "Twitter Color Emoji";
        };

        sizes = {
          desktop = 10;
          applications = 10;
          terminal = 12;
        };
      };

      cursor = {
        name = "phinger-cursors-light";
        package = pkgs.phinger-cursors;
        size = 32;
      };
    };

    fonts = {
      packages = mkAfter config.nixfiles.modules.common.stylix.fonts.extraPackages;

      fontconfig = {
        enable = this.isHeadful;

        defaultFonts = with config.stylix.fonts; {
          serif = mkForce [
            serif.name
            "Sarasa Gothic"
            "Source Han Serif"
            "Noto Serif"
          ];
          sansSerif = mkForce [
            sansSerif.name
            "Sarasa Gothic"
            "Source Han Sans"
            "Noto Sans"
          ];
          monospace = mkForce [
            monospace.name
            "Sarasa Mono"
            "Source Han Mono"
            "Noto Sans Mono"
          ];
          emoji = mkForce [
            emoji.name
            "Noto Color Emoji"
          ];
        };
      };
    };
  };
}

Consider giving Nix/NixOS a try! <3