2020-04-24 23:36:52 +00:00
|
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
|
|
cfg = config.services.xserver.displayManager;
|
2021-05-20 23:08:51 +00:00
|
|
|
|
gdm = pkgs.gnome.gdm;
|
2021-10-04 12:37:57 +00:00
|
|
|
|
settingsFormat = pkgs.formats.ini { };
|
|
|
|
|
configFile = settingsFormat.generate "custom.conf" cfg.gdm.settings;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
xSessionWrapper = if (cfg.setupCommands == "") then null else
|
|
|
|
|
pkgs.writeScript "gdm-x-session-wrapper" ''
|
|
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
|
${cfg.setupCommands}
|
|
|
|
|
exec "$@"
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
# Solves problems like:
|
|
|
|
|
# https://wiki.archlinux.org/index.php/Talk:Bluetooth_headset#GDMs_pulseaudio_instance_captures_bluetooth_headset
|
|
|
|
|
# Instead of blacklisting plugins, we use Fedora's PulseAudio configuration for GDM:
|
|
|
|
|
# https://src.fedoraproject.org/rpms/gdm/blob/master/f/default.pa-for-gdm
|
|
|
|
|
pulseConfig = pkgs.writeText "default.pa" ''
|
|
|
|
|
load-module module-device-restore
|
|
|
|
|
load-module module-card-restore
|
|
|
|
|
load-module module-udev-detect
|
|
|
|
|
load-module module-native-protocol-unix
|
|
|
|
|
load-module module-default-device-restore
|
|
|
|
|
load-module module-always-sink
|
|
|
|
|
load-module module-intended-roles
|
|
|
|
|
load-module module-suspend-on-idle
|
|
|
|
|
load-module module-position-event-sounds
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
defaultSessionName = config.services.xserver.displayManager.defaultSession;
|
|
|
|
|
|
|
|
|
|
setSessionScript = pkgs.callPackage ./account-service-util.nix { };
|
|
|
|
|
in
|
|
|
|
|
|
|
|
|
|
{
|
2020-07-18 16:06:22 +00:00
|
|
|
|
imports = [
|
|
|
|
|
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "gdm" "autoLogin" "enable" ] [
|
|
|
|
|
"services"
|
|
|
|
|
"xserver"
|
|
|
|
|
"displayManager"
|
|
|
|
|
"autoLogin"
|
|
|
|
|
"enable"
|
|
|
|
|
])
|
|
|
|
|
(mkRenamedOptionModule [ "services" "xserver" "displayManager" "gdm" "autoLogin" "user" ] [
|
|
|
|
|
"services"
|
|
|
|
|
"xserver"
|
|
|
|
|
"displayManager"
|
|
|
|
|
"autoLogin"
|
|
|
|
|
"user"
|
|
|
|
|
])
|
2022-02-10 20:34:41 +00:00
|
|
|
|
|
|
|
|
|
(mkRemovedOptionModule [ "services" "xserver" "displayManager" "gdm" "nvidiaWayland" ] "We defer to GDM whether Wayland should be enabled.")
|
2020-07-18 16:06:22 +00:00
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
|
maintainers = teams.gnome.members;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
|
|
services.xserver.displayManager.gdm = {
|
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
|
enable = mkEnableOption (lib.mdDoc "GDM, the GNOME Display Manager");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
|
debug = mkEnableOption (lib.mdDoc "debugging messages in GDM");
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2020-07-18 16:06:22 +00:00
|
|
|
|
# Auto login options specific to GDM
|
|
|
|
|
autoLogin.delay = mkOption {
|
|
|
|
|
type = types.int;
|
|
|
|
|
default = 0;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-07-18 16:06:22 +00:00
|
|
|
|
Seconds of inactivity after which the autologin will be performed.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
wayland = mkOption {
|
2020-05-03 17:38:23 +00:00
|
|
|
|
type = types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
default = true;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2020-04-24 23:36:52 +00:00
|
|
|
|
Allow GDM to run on Wayland instead of Xserver.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
autoSuspend = mkOption {
|
|
|
|
|
default = true;
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2021-07-03 03:11:41 +00:00
|
|
|
|
On the GNOME Display Manager login screen, suspend the machine after inactivity.
|
|
|
|
|
(Does not affect automatic suspend while logged in, or at lock screen.)
|
2020-04-24 23:36:52 +00:00
|
|
|
|
'';
|
|
|
|
|
type = types.bool;
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
banner = mkOption {
|
|
|
|
|
type = types.nullOr types.lines;
|
|
|
|
|
default = null;
|
|
|
|
|
example = ''
|
|
|
|
|
foo
|
|
|
|
|
bar
|
|
|
|
|
baz
|
|
|
|
|
'';
|
|
|
|
|
description = lib.mdDoc ''
|
|
|
|
|
Optional message to display on the login screen.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-04 12:37:57 +00:00
|
|
|
|
settings = mkOption {
|
|
|
|
|
type = settingsFormat.type;
|
|
|
|
|
default = { };
|
|
|
|
|
example = {
|
|
|
|
|
debug.enable = true;
|
|
|
|
|
};
|
2022-08-12 12:06:08 +00:00
|
|
|
|
description = lib.mdDoc ''
|
2021-10-04 12:37:57 +00:00
|
|
|
|
Options passed to the gdm daemon.
|
2022-08-12 12:06:08 +00:00
|
|
|
|
See [here](https://help.gnome.org/admin/gdm/stable/configuration.html.en#daemonconfig) for supported options.
|
2021-10-04 12:37:57 +00:00
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
|
|
config = mkIf cfg.gdm.enable {
|
|
|
|
|
|
|
|
|
|
services.xserver.displayManager.lightdm.enable = false;
|
|
|
|
|
|
|
|
|
|
users.users.gdm =
|
|
|
|
|
{ name = "gdm";
|
|
|
|
|
uid = config.ids.uids.gdm;
|
|
|
|
|
group = "gdm";
|
|
|
|
|
home = "/run/gdm";
|
|
|
|
|
description = "GDM user";
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
users.groups.gdm.gid = config.ids.gids.gdm;
|
|
|
|
|
|
|
|
|
|
# GDM needs different xserverArgs, presumable because using wayland by default.
|
|
|
|
|
services.xserver.tty = null;
|
|
|
|
|
services.xserver.display = null;
|
|
|
|
|
services.xserver.verbose = null;
|
|
|
|
|
|
|
|
|
|
services.xserver.displayManager.job =
|
|
|
|
|
{
|
|
|
|
|
environment = {
|
|
|
|
|
GDM_X_SERVER_EXTRA_ARGS = toString
|
|
|
|
|
(filter (arg: arg != "-terminate") cfg.xserverArgs);
|
2022-05-18 14:49:53 +00:00
|
|
|
|
XDG_DATA_DIRS = lib.makeSearchPath "share" [
|
|
|
|
|
gdm # for gnome-login.session
|
|
|
|
|
cfg.sessionData.desktops
|
|
|
|
|
pkgs.gnome.gnome-control-center # for accessibility icon
|
|
|
|
|
pkgs.gnome.adwaita-icon-theme
|
|
|
|
|
pkgs.hicolor-icon-theme # empty icon theme as a base
|
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
} // optionalAttrs (xSessionWrapper != null) {
|
|
|
|
|
# Make GDM use this wrapper before running the session, which runs the
|
|
|
|
|
# configured setupCommands. This relies on a patched GDM which supports
|
|
|
|
|
# this environment variable.
|
|
|
|
|
GDM_X_SESSION_WRAPPER = "${xSessionWrapper}";
|
|
|
|
|
};
|
|
|
|
|
execCmd = "exec ${gdm}/bin/gdm";
|
|
|
|
|
preStart = optionalString (defaultSessionName != null) ''
|
|
|
|
|
# Set default session in session chooser to a specified values – basically ignore session history.
|
|
|
|
|
${setSessionScript}/bin/set-session ${cfg.sessionData.autologinSession}
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
|
"d /run/gdm/.config 0711 gdm gdm"
|
|
|
|
|
] ++ optionals config.hardware.pulseaudio.enable [
|
|
|
|
|
"d /run/gdm/.config/pulse 0711 gdm gdm"
|
|
|
|
|
"L+ /run/gdm/.config/pulse/${pulseConfig.name} - - - - ${pulseConfig}"
|
2021-05-20 23:08:51 +00:00
|
|
|
|
] ++ optionals config.services.gnome.gnome-initial-setup.enable [
|
2020-04-24 23:36:52 +00:00
|
|
|
|
# Create stamp file for gnome-initial-setup to prevent it starting in GDM.
|
|
|
|
|
"f /run/gdm/.config/gnome-initial-setup-done 0711 gdm gdm - yes"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
# Otherwise GDM will not be able to start correctly and display Wayland sessions
|
2021-05-20 23:08:51 +00:00
|
|
|
|
systemd.packages = with pkgs.gnome; [ gdm gnome-session gnome-shell ];
|
|
|
|
|
environment.systemPackages = [ pkgs.gnome.adwaita-icon-theme ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
2021-08-12 14:41:47 +00:00
|
|
|
|
# We dont use the upstream gdm service
|
|
|
|
|
# it has to be disabled since the gdm package has it
|
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/108672
|
|
|
|
|
systemd.services.gdm.enable = false;
|
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
systemd.services.display-manager.wants = [
|
|
|
|
|
# Because sd_login_monitor_new requires /run/systemd/machines
|
|
|
|
|
"systemd-machined.service"
|
|
|
|
|
# setSessionScript wants AccountsService
|
|
|
|
|
"accounts-daemon.service"
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
systemd.services.display-manager.after = [
|
|
|
|
|
"rc-local.service"
|
|
|
|
|
"systemd-machined.service"
|
|
|
|
|
"systemd-user-sessions.service"
|
|
|
|
|
"getty@tty${gdm.initialVT}.service"
|
|
|
|
|
"plymouth-quit.service"
|
|
|
|
|
"plymouth-start.service"
|
|
|
|
|
];
|
|
|
|
|
systemd.services.display-manager.conflicts = [
|
2021-02-22 21:28:39 +00:00
|
|
|
|
"getty@tty${gdm.initialVT}.service"
|
|
|
|
|
"plymouth-quit.service"
|
2020-04-24 23:36:52 +00:00
|
|
|
|
];
|
|
|
|
|
systemd.services.display-manager.onFailure = [
|
|
|
|
|
"plymouth-quit.service"
|
|
|
|
|
];
|
|
|
|
|
|
2021-02-22 21:28:39 +00:00
|
|
|
|
# Prevent nixos-rebuild switch from bringing down the graphical
|
|
|
|
|
# session. (If multi-user.target wants plymouth-quit.service which
|
|
|
|
|
# conflicts display-manager.service, then when nixos-rebuild
|
|
|
|
|
# switch starts multi-user.target, display-manager.service is
|
|
|
|
|
# stopped so plymouth-quit.service can be started.)
|
2023-07-15 17:15:38 +00:00
|
|
|
|
systemd.services.plymouth-quit = mkIf config.boot.plymouth.enable {
|
|
|
|
|
wantedBy = lib.mkForce [];
|
|
|
|
|
};
|
2021-02-22 21:28:39 +00:00
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
|
systemd.services.display-manager.serviceConfig = {
|
|
|
|
|
# Restart = "always"; - already defined in xserver.nix
|
|
|
|
|
KillMode = "mixed";
|
|
|
|
|
IgnoreSIGPIPE = "no";
|
|
|
|
|
BusName = "org.gnome.DisplayManager";
|
|
|
|
|
StandardError = "inherit";
|
|
|
|
|
ExecReload = "${pkgs.coreutils}/bin/kill -SIGHUP $MAINPID";
|
|
|
|
|
KeyringMode = "shared";
|
|
|
|
|
EnvironmentFile = "-/etc/locale.conf";
|
|
|
|
|
};
|
|
|
|
|
|
2021-05-20 23:08:51 +00:00
|
|
|
|
systemd.services.display-manager.path = [ pkgs.gnome.gnome-session ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
# Allow choosing an user account
|
|
|
|
|
services.accounts-daemon.enable = true;
|
|
|
|
|
|
|
|
|
|
services.dbus.packages = [ gdm ];
|
|
|
|
|
|
|
|
|
|
systemd.user.services.dbus.wantedBy = [ "default.target" ];
|
|
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
|
programs.dconf.profiles.gdm.databases = lib.optionals (!cfg.gdm.autoSuspend) [{
|
|
|
|
|
settings."org/gnome/settings-daemon/plugins/power" = {
|
|
|
|
|
sleep-inactive-ac-type = "nothing";
|
|
|
|
|
sleep-inactive-battery-type = "nothing";
|
|
|
|
|
sleep-inactive-ac-timeout = lib.gvariant.mkInt32 0;
|
|
|
|
|
sleep-inactive-battery-timeout = lib.gvariant.mkInt32 0;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
|
}] ++ lib.optionals (cfg.gdm.banner != null) [{
|
|
|
|
|
settings."org/gnome/login-screen" = {
|
|
|
|
|
banner-message-enable = true;
|
|
|
|
|
banner-message-text = cfg.gdm.banner;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
};
|
2023-10-09 19:29:22 +00:00
|
|
|
|
}] ++ [ "${gdm}/share/gdm/greeter-dconf-defaults" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
# Use AutomaticLogin if delay is zero, because it's immediate.
|
|
|
|
|
# Otherwise with TimedLogin with zero seconds the prompt is still
|
|
|
|
|
# presented and there's a little delay.
|
2021-10-04 12:37:57 +00:00
|
|
|
|
services.xserver.displayManager.gdm.settings = {
|
|
|
|
|
daemon = mkMerge [
|
|
|
|
|
{ WaylandEnable = cfg.gdm.wayland; }
|
|
|
|
|
# nested if else didn't work
|
|
|
|
|
(mkIf (cfg.autoLogin.enable && cfg.gdm.autoLogin.delay != 0 ) {
|
|
|
|
|
TimedLoginEnable = true;
|
|
|
|
|
TimedLogin = cfg.autoLogin.user;
|
|
|
|
|
TimedLoginDelay = cfg.gdm.autoLogin.delay;
|
|
|
|
|
})
|
|
|
|
|
(mkIf (cfg.autoLogin.enable && cfg.gdm.autoLogin.delay == 0 ) {
|
|
|
|
|
AutomaticLoginEnable = true;
|
|
|
|
|
AutomaticLogin = cfg.autoLogin.user;
|
|
|
|
|
})
|
|
|
|
|
];
|
|
|
|
|
debug = mkIf cfg.gdm.debug {
|
|
|
|
|
Enable = true;
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
environment.etc."gdm/custom.conf".source = configFile;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
environment.etc."gdm/Xsession".source = config.services.xserver.displayManager.sessionData.wrapper;
|
|
|
|
|
|
|
|
|
|
# GDM LFS PAM modules, adapted somehow to NixOS
|
|
|
|
|
security.pam.services = {
|
|
|
|
|
gdm-launch-environment.text = ''
|
|
|
|
|
auth required pam_succeed_if.so audit quiet_success user = gdm
|
|
|
|
|
auth optional pam_permit.so
|
|
|
|
|
|
|
|
|
|
account required pam_succeed_if.so audit quiet_success user = gdm
|
|
|
|
|
account sufficient pam_unix.so
|
|
|
|
|
|
|
|
|
|
password required pam_deny.so
|
|
|
|
|
|
|
|
|
|
session required pam_succeed_if.so audit quiet_success user = gdm
|
2021-08-22 07:53:02 +00:00
|
|
|
|
session required pam_env.so conffile=/etc/pam/environment readenv=0
|
2022-05-18 14:49:53 +00:00
|
|
|
|
session optional ${config.systemd.package}/lib/security/pam_systemd.so
|
2020-04-24 23:36:52 +00:00
|
|
|
|
session optional pam_keyinit.so force revoke
|
|
|
|
|
session optional pam_permit.so
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
gdm-password.text = ''
|
|
|
|
|
auth substack login
|
|
|
|
|
account include login
|
|
|
|
|
password substack login
|
|
|
|
|
session include login
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
gdm-autologin.text = ''
|
|
|
|
|
auth requisite pam_nologin.so
|
|
|
|
|
|
|
|
|
|
auth required pam_succeed_if.so uid >= 1000 quiet
|
|
|
|
|
auth required pam_permit.so
|
|
|
|
|
|
|
|
|
|
account sufficient pam_unix.so
|
|
|
|
|
|
2023-03-27 19:17:25 +00:00
|
|
|
|
password requisite pam_unix.so nullok yescrypt
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
|
|
session optional pam_keyinit.so revoke
|
|
|
|
|
session include login
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|