summaryrefslogtreecommitdiff
path: root/modules/nixos/personal/gui.nix
blob: b3391103b7102edf2da4af7dbedd85f3552ad31d (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
112
113
114
115
116
117
{
  config,
  lib,
  pkgs,
  ...
}@extraArgs:
let
  cfg = config.personal.gui;
  wallpaper = pkgs.personal.static.wallpapers.nga-1973-68-1.override { gravity = "north"; };
  importedStylix = extraArgs ? stylix;
in
{
  imports = lib.optional importedStylix extraArgs.stylix.nixosModules.stylix;

  options.personal.gui = {
    enable = lib.mkEnableOption "GUI";
    xserver.enable = lib.mkEnableOption "X server";
    i3.enable = lib.mkEnableOption "i3";
    stylix.enable = lib.mkEnableOption "stylix";
  };

  config = lib.mkIf cfg.enable (
    lib.mkMerge [
      {
        services.xserver = lib.mkIf cfg.xserver.enable {
          enable = true;
          desktopManager.xfce.enable = true;
          displayManager = {
            lightdm = {
              enable = true;
              background = config.stylix.image or wallpaper;
              greeters.gtk = {
                enable = true;
                extraConfig = ''
                  user-background = false
                '';
                theme = lib.mkDefault {
                  name = "Arc-Dark";
                  package = pkgs.arc-theme;
                };
                iconTheme = lib.mkDefault {
                  name = "Breeze-dark";
                  package = pkgs.kdePackages.breeze-icons;
                };
              };
            };
          };
          # Hardware
          xkb.layout = config.personal.hardware.keyboard.keyMap;
          autoRepeatDelay = 200;
        };
      }
      # fragile conf
      (lib.mkIf cfg.i3.enable {
        services = {
          displayManager.defaultSession = "xfce+i3";
          libinput.enable = true;
          xserver = {
            desktopManager.xfce = {
              noDesktop = true;
              enableXfwm = false;
            };
            windowManager.i3.enable = true;
          };
        };
        security.pam.services = {
          i3lock.enable = true;
          i3lock-color.enable = true;
        };
      })
      (lib.mkIf cfg.stylix.enable (
        {
          assertions =
            let
              missingArgAssertion = name: {
                assertion = lib.hasAttr name extraArgs;
                message = "attribute ${name} missing: add it in lib.nixosSystem's specialArgs, or set config.personal.gui.stylix.enable to false";
              };
            in
            [ (missingArgAssertion "stylix") ];
        }
        // lib.optionalAttrs importedStylix {
          stylix = {
            enable = true;
            image = lib.mkDefault wallpaper;
            base16Scheme = lib.mkDefault {
              author = "Stylix";
              base00 = "212a27";
              base01 = "3a4a47";
              base02 = "596e73";
              base03 = "8ba0b5";
              base04 = "b0bbb7";
              base05 = "efe1be";
              base06 = "efefe5";
              base07 = "f1f1e5";
              base08 = "7e93a8";
              base09 = "92917f";
              base0A = "5d9c81";
              base0B = "859394";
              base0C = "8d9657";
              base0D = "b38861";
              base0E = "80977a";
              base0F = "a19052";
              scheme = "Stylix";
              slug = "stylix";
            };
            polarity = lib.mkDefault "dark";
            fonts.sizes = {
              applications = 10;
              desktop = 12;
            };
          };
        }
      ))
    ]
  );
}