1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 dmcfg = config.services.xserver.displayManager;
8 ldmcfg = dmcfg.lightdm;
9 cfg = ldmcfg.greeters.gtk;
10
11 inherit (pkgs) writeText;
12
13 theme = cfg.theme.package;
14 icons = cfg.iconTheme.package;
15
16 # The default greeter provided with this expression is the GTK greeter.
17 # Again, we need a few things in the environment for the greeter to run with
18 # fonts/icons.
19 wrappedGtkGreeter = pkgs.runCommand "lightdm-gtk-greeter"
20 { buildInputs = [ pkgs.makeWrapper ]; }
21 ''
22 # This wrapper ensures that we actually get themes
23 makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
24 $out/greeter \
25 --prefix PATH : "${pkgs.glibc.bin}/bin" \
26 --set GDK_PIXBUF_MODULE_FILE "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" \
27 --set GTK_PATH "${theme}:${pkgs.gtk3.out}" \
28 --set GTK_EXE_PREFIX "${theme}" \
29 --set GTK_DATA_PREFIX "${theme}" \
30 --set XDG_DATA_DIRS "${theme}/share:${icons}/share" \
31 --set XDG_CONFIG_HOME "${theme}/share"
32
33 cat - > $out/lightdm-gtk-greeter.desktop << EOF
34 [Desktop Entry]
35 Name=LightDM Greeter
36 Comment=This runs the LightDM Greeter
37 Exec=$out/greeter
38 Type=Application
39 EOF
40 '';
41
42 gtkGreeterConf = writeText "lightdm-gtk-greeter.conf"
43 ''
44 [greeter]
45 theme-name = ${cfg.theme.name}
46 icon-theme-name = ${cfg.iconTheme.name}
47 background = ${ldmcfg.background}
48 ${optionalString (cfg.clock-format != null) "clock-format = ${cfg.clock-format}"}
49 ${optionalString (cfg.indicators != null) "indicators = ${concatStringsSep ";" cfg.indicators}"}
50 ${cfg.extraConfig}
51 '';
52
53in
54{
55 options = {
56
57 services.xserver.displayManager.lightdm.greeters.gtk = {
58
59 enable = mkOption {
60 type = types.bool;
61 default = true;
62 description = ''
63 Whether to enable lightdm-gtk-greeter as the lightdm greeter.
64 '';
65 };
66
67 theme = {
68
69 package = mkOption {
70 type = types.package;
71 default = pkgs.gnome3.gnome-themes-extra;
72 defaultText = "pkgs.gnome3.gnome-themes-extra";
73 description = ''
74 The package path that contains the theme given in the name option.
75 '';
76 };
77
78 name = mkOption {
79 type = types.str;
80 default = "Adwaita";
81 description = ''
82 Name of the theme to use for the lightdm-gtk-greeter.
83 '';
84 };
85
86 };
87
88 iconTheme = {
89
90 package = mkOption {
91 type = types.package;
92 default = pkgs.gnome3.defaultIconTheme;
93 defaultText = "pkgs.gnome3.defaultIconTheme";
94 description = ''
95 The package path that contains the icon theme given in the name option.
96 '';
97 };
98
99 name = mkOption {
100 type = types.str;
101 default = "Adwaita";
102 description = ''
103 Name of the icon theme to use for the lightdm-gtk-greeter.
104 '';
105 };
106
107 };
108
109 clock-format = mkOption {
110 type = types.nullOr types.str;
111 default = null;
112 example = "%F";
113 description = ''
114 Clock format string (as expected by strftime, e.g. "%H:%M")
115 to use with the lightdm gtk greeter panel.
116
117 If set to null the default clock format is used.
118 '';
119 };
120
121 indicators = mkOption {
122 type = types.nullOr (types.listOf types.str);
123 default = null;
124 example = [ "~host" "~spacer" "~clock" "~spacer" "~session" "~language" "~a11y" "~power" ];
125 description = ''
126 List of allowed indicator modules to use for the lightdm gtk
127 greeter panel.
128
129 Built-in indicators include "~a11y", "~language", "~session",
130 "~power", "~clock", "~host", "~spacer". Unity indicators can be
131 represented by short name (e.g. "sound", "power"), service file name,
132 or absolute path.
133
134 If set to null the default indicators are used.
135 '';
136 };
137
138 extraConfig = mkOption {
139 type = types.lines;
140 default = "";
141 description = ''
142 Extra configuration that should be put in the lightdm-gtk-greeter.conf
143 configuration file.
144 '';
145 };
146
147 };
148
149 };
150
151 config = mkIf (ldmcfg.enable && cfg.enable) {
152
153 services.xserver.displayManager.lightdm.greeter = mkDefault {
154 package = wrappedGtkGreeter;
155 name = "lightdm-gtk-greeter";
156 };
157
158 environment.etc."lightdm/lightdm-gtk-greeter.conf".source = gtkGreeterConf;
159
160 };
161}