2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2013-03-25 18:26:07 +00:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2013-03-25 18:26:07 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
dmcfg = config.services.xserver.displayManager;
|
2013-09-09 09:22:08 +01:00
|
|
|
xEnv = config.systemd.services."display-manager".environment;
|
2013-03-25 18:26:07 +00: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 09:22:08 +01:00
|
|
|
${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)}
|
2013-03-25 18:26:07 +00:00
|
|
|
exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs}
|
|
|
|
'';
|
|
|
|
|
2015-03-10 21:23:43 +00:00
|
|
|
theme = pkgs.gnome3.gnome_themes_standard;
|
2015-04-10 16:02:57 +01:00
|
|
|
icons = pkgs.gnome3.defaultIconTheme;
|
2015-03-10 21:23:43 +00:00
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
# 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 21:03:12 +00:00
|
|
|
# This wrapper ensures that we actually get themes
|
2013-03-25 18:26:07 +00:00
|
|
|
makeWrapper ${pkgs.lightdm_gtk_greeter}/sbin/lightdm-gtk-greeter \
|
|
|
|
$out/greeter \
|
2015-03-10 21:03:12 +00:00
|
|
|
--prefix PATH : "${pkgs.glibc}/bin" \
|
2015-07-15 23:30:39 +01:00
|
|
|
--set GDK_PIXBUF_MODULE_FILE "${pkgs.gdk_pixbuf}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache" \
|
2015-03-10 21:23:43 +00:00
|
|
|
--set GTK_PATH "${theme}:${pkgs.gtk3}" \
|
|
|
|
--set GTK_EXE_PREFIX "${theme}" \
|
|
|
|
--set GTK_DATA_PREFIX "${theme}" \
|
|
|
|
--set XDG_DATA_DIRS "${theme}/share:${icons}/share" \
|
|
|
|
--set XDG_CONFIG_HOME "${theme}/share"
|
2013-03-25 18:26:07 +00:00
|
|
|
|
|
|
|
cat - > $out/lightdm-gtk-greeter.desktop << EOF
|
2013-04-22 20:31:29 +01:00
|
|
|
[Desktop Entry]
|
|
|
|
Name=LightDM Greeter
|
|
|
|
Comment=This runs the LightDM Greeter
|
|
|
|
Exec=$out/greeter
|
|
|
|
Type=Application
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
};
|
2013-03-25 18:26:07 +00:00
|
|
|
|
2015-03-10 01:04:40 +00:00
|
|
|
usersConf = writeText "users.conf"
|
|
|
|
''
|
|
|
|
[UserList]
|
|
|
|
minimum-uid=500
|
2015-03-10 21:35:49 +00:00
|
|
|
hidden-users=${concatStringsSep " " dmcfg.hiddenUsers}
|
2015-04-01 21:57:06 +01:00
|
|
|
hidden-shells=/run/current-system/sw/bin/nologin
|
2015-03-10 01:04:40 +00:00
|
|
|
'';
|
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
lightdmConf = writeText "lightdm.conf"
|
|
|
|
''
|
2013-04-22 20:31:29 +01:00
|
|
|
[LightDM]
|
|
|
|
greeter-user = ${config.users.extraUsers.lightdm.name}
|
2014-01-31 11:11:04 +00:00
|
|
|
greeters-directory = ${cfg.greeter.package}
|
|
|
|
sessions-directory = ${dmcfg.session.desktops}
|
2013-03-25 18:26:07 +00:00
|
|
|
|
2015-05-20 23:12:55 +01:00
|
|
|
[Seat:*]
|
2013-04-22 20:31:29 +01:00
|
|
|
xserver-command = ${xserverWrapper}
|
|
|
|
session-wrapper = ${dmcfg.session.script}
|
|
|
|
greeter-session = ${cfg.greeter.name}
|
2015-04-18 20:14:10 +01:00
|
|
|
${cfg.extraSeatDefaults}
|
2013-03-25 18:26:07 +00:00
|
|
|
'';
|
|
|
|
|
2015-03-10 21:03:12 +00:00
|
|
|
gtkGreeterConf = writeText "lightdm-gtk-greeter.conf"
|
|
|
|
''
|
|
|
|
[greeter]
|
|
|
|
theme-name = Adwaita
|
|
|
|
icon-theme-name = Adwaita
|
2015-03-10 22:57:46 +00:00
|
|
|
background = ${cfg.background}
|
2015-03-10 21:03:12 +00:00
|
|
|
'';
|
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.xserver.displayManager.lightdm = {
|
2015-03-10 21:55:54 +00:00
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
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 01:04:40 +00:00
|
|
|
|
2015-03-10 22:57:46 +00:00
|
|
|
background = mkOption {
|
|
|
|
description = ''
|
|
|
|
The background image or color to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-04-18 20:14:10 +01:00
|
|
|
extraSeatDefaults = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = ''
|
|
|
|
greeter-show-manual-login=true
|
|
|
|
'';
|
|
|
|
description = "Extra lines to append to SeatDefaults section.";
|
|
|
|
};
|
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2013-10-15 16:22:30 +01:00
|
|
|
|
|
|
|
services.xserver.displayManager.slim.enable = false;
|
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
services.xserver.displayManager.job = {
|
|
|
|
logsXsession = true;
|
|
|
|
|
|
|
|
# lightdm relaunches itself via just `lightdm`, so needs to be on the PATH
|
2013-10-28 00:14:16 +00:00
|
|
|
execCmd = ''
|
2013-03-25 18:26:07 +00:00
|
|
|
export PATH=${lightdm}/sbin:$PATH
|
2015-03-10 00:59:21 +00:00
|
|
|
exec ${lightdm}/sbin/lightdm --log-dir=/var/log --run-dir=/run
|
2013-03-25 18:26:07 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2015-03-10 21:03:12 +00:00
|
|
|
environment.etc."lightdm/lightdm-gtk-greeter.conf".source = gtkGreeterConf;
|
2015-03-10 00:59:21 +00:00
|
|
|
environment.etc."lightdm/lightdm.conf".source = lightdmConf;
|
2015-03-10 01:04:40 +00:00
|
|
|
environment.etc."lightdm/users.conf".source = usersConf;
|
2015-03-10 00:59:21 +00:00
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
services.dbus.enable = true;
|
|
|
|
services.dbus.packages = [ lightdm ];
|
|
|
|
|
2015-05-22 03:06:03 +01:00
|
|
|
security.pam.services.lightdm = {
|
|
|
|
allowNullPassword = true;
|
|
|
|
startSession = true;
|
|
|
|
};
|
|
|
|
security.pam.services.lightdm-greeter = {
|
|
|
|
allowNullPassword = true;
|
|
|
|
startSession = true;
|
|
|
|
text = ''
|
2015-11-22 20:25:11 +00:00
|
|
|
auth required pam_env.so envfile=${config.system.build.pamEnvironment}
|
2015-05-22 03:06:03 +01:00
|
|
|
auth required pam_permit.so
|
|
|
|
|
|
|
|
account required pam_permit.so
|
|
|
|
|
|
|
|
password required pam_deny.so
|
|
|
|
|
|
|
|
session required pam_env.so envfile=${config.system.build.pamEnvironment}
|
|
|
|
session required pam_unix.so
|
|
|
|
session optional ${pkgs.systemd}/lib/security/pam_systemd.so
|
|
|
|
'';
|
|
|
|
};
|
2013-03-25 18:26:07 +00:00
|
|
|
|
|
|
|
users.extraUsers.lightdm = {
|
|
|
|
createHome = true;
|
2015-03-10 21:55:54 +00:00
|
|
|
home = "/var/lib/lightdm-data";
|
2013-08-26 14:20:25 +01:00
|
|
|
group = "lightdm";
|
|
|
|
uid = config.ids.uids.lightdm;
|
2013-03-25 18:26:07 +00:00
|
|
|
};
|
2013-08-26 14:20:25 +01:00
|
|
|
|
|
|
|
users.extraGroups.lightdm.gid = config.ids.gids.lightdm;
|
2015-09-24 10:42:32 +01:00
|
|
|
|
|
|
|
services.xserver.displayManager.lightdm.background = mkDefault "${pkgs.nixos-artwork}/share/artwork/gnome/Gnome_Dark.png";
|
|
|
|
|
2013-03-25 18:26:07 +00:00
|
|
|
};
|
|
|
|
}
|