summaryrefslogtreecommitdiff
path: root/modules/nixos/personal/gui.nix
blob: 52e57131ecfee43fceb253782f1da9764bab7229 (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
{
  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 = lib.mkDefault (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.breeze-icons;
              };
            };
          };
        };
        # Hardware
        xkb.layout = config.personal.hardware.keyboard.keyMap;
        autoRepeatDelay = 200;
      };
    }
    # fragile conf
    (lib.mkIf cfg.i3.enable (
      lib.mkMerge [
        {
          services = {
            xserver = {
              desktopManager.xfce = {
                noDesktop = true;
                enableXfwm = false;
              };
              windowManager.i3.enable = true;
            };
          };
        }
        (
          let
            conf = {
              displayManager.defaultSession = "xfce+i3";
              libinput.enable = true;
            };
          in
            if (builtins.compareVersions lib.trivial.version "23.11" > 0)
            then {services = conf;}
            else {services.xserver = conf;}
        )
      ]
    ))
    (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 = {
          image = lib.mkDefault wallpaper;
          polarity = lib.mkDefault "dark";
          fonts.sizes = {
            applications = 10;
            desktop = 12;
          };
        };
      }))
  ]);
}