summaryrefslogtreecommitdiff
path: root/modules/nixfiles/x11.nix
blob: 502a24b838b5e2b65615121be36ac23f0b847ea4 (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.x11;
in {
  options.nixfiles.modules.x11.enable = mkEnableOption "X11";

  config = mkIf cfg.enable {
    nixfiles.modules.fonts.enable = true;

    hm = {
      home = {
        # TODO Get these out of the global state.
        # packages = with pkgs;
        #   [xclip xdotool]
        #   ++ (with xorg; [
        #     xdpyinfo
        #     xdriinfo
        #     xev
        #     xfontsel
        #     xkill
        #     xlsatoms
        #     xlsclients
        #     xlsfonts
        #     xprop
        #     xrandr
        #     xwininfo
        #   ]);

        sessionVariables = with config.dirs; {
          XCOMPOSEFILE = "${cache}/XComposeFile";
          XCOMPOSECACHE = "${cache}/XComposeCache";
        };
      };

      xsession.scriptPath = ".xinitrc";

      xresources.properties = with config.nixfiles.modules; let
        font = with config.fontScheme.monospaceFont; "${family}:style=${style}:size=${toString size}";
      in
        {
          "*.font" = font;

          "Xft.antialias" = 1;
          "Xft.autohint" = 0;
          "Xft.dpi" = 96;
          "Xft.hinting" = 1;
          "Xft.hintstyle" = "hintslight";
          "Xft.lcdfilter" = "lcddefault";
          "Xft.rgba" = "rgb";
        }
        // (with profiles.common.colourScheme; {
          "*.color0" = black;
          "*.color8" = brightBlack;
          "*.color1" = red;
          "*.color9" = brightRed;
          "*.color2" = green;
          "*.color10" = brightGreen;
          "*.color3" = yellow;
          "*.color11" = brightYellow;
          "*.color4" = blue;
          "*.color12" = brightBlue;
          "*.color5" = magenta;
          "*.color13" = brightMagenta;
          "*.color6" = cyan;
          "*.color14" = brightCyan;
          "*.color7" = white;
          "*.color15" = brightWhite;

          "*.background" = background;
          "*.foreground" = foreground;
        });
    };

    services.xserver = {
      enable = true;

      tty = mkDefault 1;

      autoRepeatDelay = 200;
      autoRepeatInterval = 25;

      libinput.enable = true;

      monitorSection = ''
        Option "DPMS" "false"
      '';

      serverFlagsSection = ''
        Option "BlankTime" "0"
        Option "OffTime" "0"
        Option "StandbyTime" "0"
        Option "SuspendTime" "0"
      '';

      inputClassSections = [
        ''
          Identifier "Mouse"
          MatchIsPointer "yes"
          Option "AccelerationNumerator" "2"
          Option "AccelerationDenominator" "1"
          Option "AccelerationThreshold" "4"
        ''
      ];
    };
  };
}