2014-04-14 16:26:48 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-03-25 19:26:07 +01:00
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
with lib;
|
2013-03-25 19:26:07 +01:00
|
|
|
|
|
|
|
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 = ''
|
2015-03-10 22:03:12 +01:00
|
|
|
# This wrapper ensures that we actually get themes
|
2013-03-25 19:26:07 +01:00
|
|
|
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
|
|
|
|
$out/greeter \
|
2015-03-10 22:03:12 +01:00
|
|
|
--prefix PATH : "${pkgs.glibc}/bin" \
|
|
|
|
--set GTK_DATA_PREFIX "${pkgs.gnome3.gnome_themes_standard}" \
|
|
|
|
--set GTK_EXE_PREFIX "${pkgs.gnome3.gnome_themes_standard}" \
|
|
|
|
--set GTK_PATH "${pkgs.gnome3.gnome_themes_standard}" \
|
|
|
|
--set XDG_DATA_DIRS "${pkgs.gnome3.gnome_themes_standard}/share:${pkgs.gnome3.gnome_icon_theme}/share" \
|
|
|
|
--set XDG_CONFIG_HOME ${pkgs.gnome3.gnome_themes_standard}/share
|
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
|
|
|
|
2015-03-10 02:04:40 +01:00
|
|
|
hiddenUsers = config.services.xserver.displayManager.hiddenUsers;
|
|
|
|
|
|
|
|
usersConf = writeText "users.conf"
|
|
|
|
''
|
|
|
|
[UserList]
|
|
|
|
minimum-uid=500
|
|
|
|
hidden-users=${concatStringsSep " " hiddenUsers}
|
|
|
|
hidden-shells=/run/current-system/sw/sbin/nologin
|
|
|
|
'';
|
|
|
|
|
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}
|
2014-01-31 12:11:04 +01:00
|
|
|
greeters-directory = ${cfg.greeter.package}
|
|
|
|
sessions-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
|
|
|
'';
|
|
|
|
|
2015-03-10 22:03:12 +01:00
|
|
|
gtkGreeterConf = writeText "lightdm-gtk-greeter.conf"
|
|
|
|
''
|
|
|
|
[greeter]
|
|
|
|
theme-name = Adwaita
|
|
|
|
icon-theme-name = Adwaita
|
|
|
|
'';
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
};
|
2015-03-10 02:04:40 +01:00
|
|
|
|
2013-03-25 19:26:07 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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-28 01:14:16 +01:00
|
|
|
execCmd = ''
|
2013-03-25 19:26:07 +01:00
|
|
|
export PATH=${lightdm}/sbin:$PATH
|
2015-03-10 01:59:21 +01:00
|
|
|
exec ${lightdm}/sbin/lightdm --log-dir=/var/log --run-dir=/run
|
2013-03-25 19:26:07 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-03-10 22:03:12 +01:00
|
|
|
environment.etc."lightdm/lightdm-gtk-greeter.conf".source = gtkGreeterConf;
|
2015-03-10 01:59:21 +01:00
|
|
|
environment.etc."lightdm/lightdm.conf".source = lightdmConf;
|
2015-03-10 02:04:40 +01:00
|
|
|
environment.etc."lightdm/users.conf".source = usersConf;
|
2015-03-10 01:59:21 +01:00
|
|
|
|
2013-03-25 19:26:07 +01:00
|
|
|
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
|
|
|
};
|
|
|
|
}
|