aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/x11/display-managers/default.nix')
-rw-r--r--nixpkgs/nixos/modules/services/x11/display-managers/default.nix64
1 files changed, 57 insertions, 7 deletions
diff --git a/nixpkgs/nixos/modules/services/x11/display-managers/default.nix b/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
index aa6a5ec42be..08ce8edd661 100644
--- a/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixpkgs/nixos/modules/services/x11/display-managers/default.nix
@@ -55,13 +55,6 @@ let
exec &> >(tee ~/.xsession-errors)
''}
- # Tell systemd about our $DISPLAY and $XAUTHORITY.
- # This is needed by the ssh-agent unit.
- #
- # Also tell systemd about the dbus session bus address.
- # This is required by user units using the session bus.
- /run/current-system/systemd/bin/systemctl --user import-environment DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
-
# Load X defaults. This should probably be safe on wayland too.
${xorg.xrdb}/bin/xrdb -merge ${xresourcesXft}
if test -e ~/.Xresources; then
@@ -70,6 +63,12 @@ let
${xorg.xrdb}/bin/xrdb -merge ~/.Xdefaults
fi
+ # Import environment variables into the systemd user environment.
+ ${optionalString (cfg.displayManager.importedVariables != []) (
+ "/run/current-system/systemd/bin/systemctl --user import-environment "
+ + toString (unique cfg.displayManager.importedVariables)
+ )}
+
# Speed up application start by 50-150ms according to
# http://kdemonkey.blogspot.nl/2008/04/magic-trick.html
rm -rf "$HOME/.compose-cache"
@@ -289,6 +288,14 @@ in
'';
};
+ importedVariables = mkOption {
+ type = types.listOf (types.strMatching "[a-zA-Z_][a-zA-Z0-9_]*");
+ visible = false;
+ description = ''
+ Environment variables to import into the systemd user environment.
+ '';
+ };
+
job = {
preStart = mkOption {
@@ -332,12 +339,45 @@ in
};
+ # Configuration for automatic login. Common for all DM.
+ autoLogin = mkOption {
+ type = types.submodule {
+ options = {
+ enable = mkOption {
+ type = types.bool;
+ default = cfg.displayManager.autoLogin.user != null;
+ description = ''
+ Automatically log in as <option>autoLogin.user</option>.
+ '';
+ };
+
+ user = mkOption {
+ type = types.nullOr types.str;
+ default = null;
+ description = ''
+ User to be used for the automatic login.
+ '';
+ };
+ };
+ };
+
+ default = {};
+ description = ''
+ Auto login configuration attrset.
+ '';
+ };
+
};
};
config = {
assertions = [
+ { assertion = cfg.displayManager.autoLogin.enable -> cfg.displayManager.autoLogin.user != null;
+ message = ''
+ services.xserver.displayManager.autoLogin.enable requires services.xserver.displayManager.autoLogin.user to be set
+ '';
+ }
{
assertion = cfg.desktopManager.default != null || cfg.windowManager.default != null -> cfg.displayManager.defaultSession == defaultSessionFromLegacyOptions;
message = "You cannot use both services.xserver.displayManager.defaultSession option and legacy options (services.xserver.desktopManager.default and services.xserver.windowManager.default).";
@@ -360,6 +400,16 @@ in
services.xserver.displayManager.xserverBin = "${xorg.xorgserver.out}/bin/X";
+ services.xserver.displayManager.importedVariables = [
+ # This is required by user units using the session bus.
+ "DBUS_SESSION_BUS_ADDRESS"
+ # These are needed by the ssh-agent unit.
+ "DISPLAY"
+ "XAUTHORITY"
+ # This is required to specify session within user units (e.g. loginctl lock-session).
+ "XDG_SESSION_ID"
+ ];
+
systemd.user.targets.graphical-session = {
unitConfig = {
RefuseManualStart = false;