2013-03-25 19:26:07 +01:00
|
|
|
{ config, pkgs, ... }:
|
|
|
|
|
|
|
|
with pkgs.lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
dmcfg = config.services.xserver.displayManager;
|
2013-09-09 10:22:08 +02:00
|
|
|
xEnv = config.systemd.services."display-manager".environment;
|
2013-03-25 19:26:07 +01:00
|
|
|
cfg = dmcfg.lightdm;
|
|
|
|
|
|
|
|
inherit (pkgs) stdenv lightdm writeScript writeText;
|
|
|
|
|
|
|
|
# lightdm runs with clearenv(), but we need a few things in the enviornment for X to startup
|
|
|
|
xserverWrapper = writeScript "xserver-wrapper"
|
|
|
|
''
|
|
|
|
#! /bin/sh
|
2013-09-09 10:22:08 +02:00
|
|
|
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
|
2013-03-25 19:26:07 +01:00
|
|
|
exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# The default greeter provided with this expression is the GTK greeter.
|
|
|
|
# Again, we need a few things in the environment for the greeter to run with
|
|
|
|
# fonts/icons.
|
|
|
|
wrappedGtkGreeter = stdenv.mkDerivation {
|
|
|
|
name = "lightdm-gtk-greeter";
|
|
|
|
buildInputs = [ pkgs.makeWrapper ];
|
|
|
|
|
|
|
|
buildCommand = ''
|
|
|
|
ensureDir $out/gtk-3.0/
|
|
|
|
|
|
|
|
# This wrapper ensures that we actually get fonts
|
|
|
|
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
|
|
|
|
$out/greeter \
|
|
|
|
--set XDG_DATA_DIRS ${pkgs.gnome2.gnome_icon_theme}/share \
|
|
|
|
--set FONTCONFIG_FILE /etc/fonts/fonts.conf \
|
|
|
|
--set XDG_CONFIG_HOME $out/
|
|
|
|
|
|
|
|
# We need this to ensure that it actually tries to find icons from gnome-icon-theme
|
|
|
|
cat - > $out/gtk-3.0/settings.ini << EOF
|
2013-04-22 21:31:29 +02:00
|
|
|
[Settings]
|
|
|
|
gtk-icon-theme-name=gnome
|
|
|
|
EOF
|
2013-03-25 19:26:07 +01:00
|
|
|
|
|
|
|
cat - > $out/lightdm-gtk-greeter.desktop << EOF
|
2013-04-22 21:31:29 +02:00
|
|
|
[Desktop Entry]
|
|
|
|
Name=LightDM Greeter
|
|
|
|
Comment=This runs the LightDM Greeter
|
|
|
|
Exec=$out/greeter
|
|
|
|
Type=Application
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
};
|
2013-03-25 19:26:07 +01:00
|
|
|
|
|
|
|
lightdmConf = writeText "lightdm.conf"
|
|
|
|
''
|
2013-04-22 21:31:29 +02:00
|
|
|
[LightDM]
|
|
|
|
greeter-user = ${config.users.extraUsers.lightdm.name}
|
|
|
|
xgreeters-directory = ${cfg.greeter.package}
|
|
|
|
xsessions-directory = ${dmcfg.session.desktops}
|
2013-03-25 19:26:07 +01:00
|
|
|
|
2013-04-22 21:31:29 +02:00
|
|
|
[SeatDefaults]
|
|
|
|
xserver-command = ${xserverWrapper}
|
|
|
|
session-wrapper = ${dmcfg.session.script}
|
|
|
|
greeter-session = ${cfg.greeter.name}
|
2013-03-25 19:26:07 +01:00
|
|
|
'';
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.xserver.displayManager.lightdm = {
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable lightdm as the display manager.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
greeter = mkOption {
|
|
|
|
description = ''
|
|
|
|
The LightDM greeter to login via. The package should be a directory
|
|
|
|
containing a .desktop file matching the name in the 'name' option.
|
|
|
|
'';
|
|
|
|
default = {
|
|
|
|
name = "lightdm-gtk-greeter";
|
|
|
|
package = wrappedGtkGreeter;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2013-10-15 17:22:30 +02:00
|
|
|
|
|
|
|
services.xserver.displayManager.slim.enable = false;
|
|
|
|
|
2013-03-25 19:26:07 +01:00
|
|
|
services.xserver.displayManager.job = {
|
|
|
|
logsXsession = true;
|
|
|
|
|
|
|
|
# lightdm relaunches itself via just `lightdm`, so needs to be on the PATH
|
2013-10-15 17:22:30 +02:00
|
|
|
execCmd = mkFixStrictness ''
|
2013-03-25 19:26:07 +01:00
|
|
|
export PATH=${lightdm}/sbin:$PATH
|
|
|
|
${lightdm}/sbin/lightdm --log-dir=/var/log --run-dir=/run --config=${lightdmConf}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
services.dbus.enable = true;
|
|
|
|
services.dbus.packages = [ lightdm ];
|
|
|
|
|
2013-10-15 14:47:51 +02:00
|
|
|
security.pam.services.lightdm = { allowNullPassword = true; startSession = true; };
|
|
|
|
security.pam.services.lightdm-greeter = { allowNullPassword = true; startSession = true; };
|
2013-03-25 19:26:07 +01:00
|
|
|
|
|
|
|
users.extraUsers.lightdm = {
|
|
|
|
createHome = true;
|
|
|
|
home = "/var/lib/lightdm";
|
2013-08-26 15:20:25 +02:00
|
|
|
group = "lightdm";
|
|
|
|
uid = config.ids.uids.lightdm;
|
2013-03-25 19:26:07 +01:00
|
|
|
};
|
2013-08-26 15:20:25 +02:00
|
|
|
|
|
|
|
users.extraGroups.lightdm.gid = config.ids.gids.lightdm;
|
2013-03-25 19:26:07 +01:00
|
|
|
};
|
|
|
|
}
|