summary refs log tree commit diff
path: root/nixos/modules/services/x11/display-managers/lightdm-greeters/enso-os.nix
blob: ecd46a9ee6d2500180f90e49f07ea61b0ceb6131 (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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
{ config, lib, pkgs, ... }:

with lib;
let
  dmcfg = config.services.xserver.displayManager;
  ldmcfg = dmcfg.lightdm;
  cfg = ldmcfg.greeters.enso;

  theme = cfg.theme.package;
  icons = cfg.iconTheme.package;
  cursors = cfg.cursorTheme.package;

  ensoGreeterConf = pkgs.writeText "lightdm-enso-os-greeter.conf" ''
    [greeter]
    default-wallpaper=${ldmcfg.background}
    gtk-theme=${cfg.theme.name}
    icon-theme=${cfg.iconTheme.name}
    cursor-theme=${cfg.cursorTheme.name}
    blur=${toString cfg.blur}
    brightness=${toString cfg.brightness}
    ${cfg.extraConfig}
  '';
in {
  options = {
    services.xserver.displayManager.lightdm.greeters.enso = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether to enable enso-os-greeter as the lightdm greeter
        '';
      };

      theme = {
        package = mkOption {
          type = types.package;
          default = pkgs.gnome.gnome-themes-extra;
          defaultText = "pkgs.gnome.gnome-themes-extra";
          description = ''
            The package path that contains the theme given in the name option.
          '';
        };

        name = mkOption {
          type = types.str;
          default = "Adwaita";
          description = ''
            Name of the theme to use for the lightdm-enso-os-greeter
          '';
        };
      };

      iconTheme = {
        package = mkOption {
          type = types.package;
          default = pkgs.papirus-icon-theme;
          defaultText = "pkgs.papirus-icon-theme";
          description = ''
            The package path that contains the icon theme given in the name option.
          '';
        };

        name = mkOption {
          type = types.str;
          default = "ePapirus";
          description = ''
            Name of the icon theme to use for the lightdm-enso-os-greeter
          '';
        };
      };

      cursorTheme = {
        package = mkOption {
          type = types.package;
          default = pkgs.capitaine-cursors;
          defaultText = "pkgs.capitaine-cursors";
          description = ''
            The package path that contains the cursor theme given in the name option.
          '';
        };

        name = mkOption {
          type = types.str;
          default = "capitane-cursors";
          description = ''
            Name of the cursor theme to use for the lightdm-enso-os-greeter
          '';
        };
      };

      blur = mkOption {
        type = types.bool;
        default = false;
        description = ''
          Whether or not to enable blur
        '';
      };

      brightness = mkOption {
        type = types.int;
        default = 7;
        description = ''
          Brightness
        '';
      };

      extraConfig = mkOption {
        type = types.lines;
        default = "";
        description = ''
          Extra configuration that should be put in the greeter.conf
          configuration file
        '';
      };
    };
  };

  config = mkIf (ldmcfg.enable && cfg.enable) {
    environment.etc."lightdm/greeter.conf".source = ensoGreeterConf;

    environment.systemPackages = [
      cursors
      icons
      theme
    ];

    services.xserver.displayManager.lightdm = {
      greeter = mkDefault {
        package = pkgs.lightdm-enso-os-greeter.xgreeters;
        name = "pantheon-greeter";
      };

      greeters = {
        gtk = {
          enable = mkDefault false;
        };
      };
    };
  };
}