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) stdenv lightdm writeScript 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.gdk_pixbuf.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 ${cfg.extraConfig}
49 '';
50
51in
52{
53 options = {
54
55 services.xserver.displayManager.lightdm.greeters.gtk = {
56
57 enable = mkOption {
58 type = types.bool;
59 default = true;
60 description = ''
61 Whether to enable lightdm-gtk-greeter as the lightdm greeter.
62 '';
63 };
64
65 theme = {
66
67 package = mkOption {
68 type = types.package;
69 default = pkgs.gnome3.gnome_themes_standard;
70 defaultText = "pkgs.gnome3.gnome_themes_standard";
71 description = ''
72 The package path that contains the theme given in the name option.
73 '';
74 };
75
76 name = mkOption {
77 type = types.str;
78 default = "Adwaita";
79 description = ''
80 Name of the theme to use for the lightdm-gtk-greeter.
81 '';
82 };
83
84 };
85
86 iconTheme = {
87
88 package = mkOption {
89 type = types.package;
90 default = pkgs.gnome3.defaultIconTheme;
91 defaultText = "pkgs.gnome3.defaultIconTheme";
92 description = ''
93 The package path that contains the icon theme given in the name option.
94 '';
95 };
96
97 name = mkOption {
98 type = types.str;
99 default = "Adwaita";
100 description = ''
101 Name of the icon theme to use for the lightdm-gtk-greeter.
102 '';
103 };
104
105 };
106
107 extraConfig = mkOption {
108 type = types.lines;
109 default = "";
110 description = ''
111 Extra configuration that should be put in the lightdm-gtk-greeter.conf
112 configuration file.
113 '';
114 };
115
116 };
117
118 };
119
120 config = mkIf (ldmcfg.enable && cfg.enable) {
121
122 services.xserver.displayManager.lightdm.greeter = mkDefault {
123 package = wrappedGtkGreeter;
124 name = "lightdm-gtk-greeter";
125 };
126
127 environment.etc."lightdm/lightdm-gtk-greeter.conf".source = gtkGreeterConf;
128
129 };
130}