From b07fa98f82ac44801dc34b6b143048ee28f7e1a3 Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sat, 12 Dec 2015 11:31:26 -0600 Subject: nixos/sddm: add setupScript and stopScript options These options allow setting the start and stop scripts for the display manager. Making these configurable is necessary to allow some hardware configurations. Upstream ships empty scripts by default, anyway. --- .../modules/services/x11/display-managers/sddm.nix | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'nixos/modules/services/x11/display-managers') diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix index d156f692f269..50e6a85b4f28 100644 --- a/nixos/modules/services/x11/display-managers/sddm.nix +++ b/nixos/modules/services/x11/display-managers/sddm.nix @@ -17,6 +17,16 @@ let exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs} "$@" ''; + Xsetup = pkgs.writeScript "Xsetup" '' + #!/bin/sh + ${cfg.setupScript} + ''; + + Xstop = pkgs.writeScript "Xstop" '' + #!/bin/sh + ${cfg.stopScript} + ''; + cfgFile = pkgs.writeText "sddm.conf" '' [General] HaltCommand=${pkgs.systemd}/bin/systemctl poweroff @@ -39,6 +49,8 @@ let SessionCommand=${dmcfg.session.script} SessionDir=${dmcfg.session.desktops} XauthPath=${pkgs.xorg.xauth}/bin/xauth + DisplayCommand=${Xsetup} + DisplayStopCommand=${Xstop} ${optionalString cfg.autoLogin.enable '' [Autologin] @@ -98,6 +110,27 @@ in ''; }; + setupScript = mkOption { + type = types.str; + default = ""; + example = '' + # workaround for using NVIDIA Optimus without Bumblebee + xrandr --setprovideroutputsource modesetting NVIDIA-0 + xrandr --auto + ''; + description = '' + A script to execute when starting the display server. + ''; + }; + + stopScript = mkOption { + type = types.str; + default = ""; + description = '' + A script to execute when stopping the display server. + ''; + }; + autoLogin = mkOption { default = {}; description = '' -- cgit 1.4.1 From fac138a2f5a784694b652f7f1f8767e7882d542c Mon Sep 17 00:00:00 2001 From: Thomas Tuegel Date: Sat, 12 Dec 2015 11:33:39 -0600 Subject: nixos/sddm: fix indentation --- nixos/modules/services/x11/display-managers/sddm.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'nixos/modules/services/x11/display-managers') diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix index 50e6a85b4f28..bcac83aa738b 100644 --- a/nixos/modules/services/x11/display-managers/sddm.nix +++ b/nixos/modules/services/x11/display-managers/sddm.nix @@ -138,7 +138,7 @@ in ''; type = types.submodule { - options = { + options = { enable = mkOption { type = types.bool; default = false; @@ -163,7 +163,7 @@ in will work only the first time. ''; }; - }; + }; }; }; @@ -175,14 +175,16 @@ in assertions = [ { assertion = cfg.autoLogin.enable -> cfg.autoLogin.user != null; - message = "SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set"; + message = '' + SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set + ''; } { assertion = cfg.autoLogin.enable -> elem defaultSessionName dmcfg.session.names; message = '' SDDM auto-login requires that services.xserver.desktopManager.default and - services.xserver.windowMananger.default are set to valid values. The current - default session: ${defaultSessionName} is not valid. - ''; + services.xserver.windowMananger.default are set to valid values. The current + default session: ${defaultSessionName} is not valid. + ''; } ]; -- cgit 1.4.1 From 9be012f0d4d9b6bca35416ec89d5a40be4556896 Mon Sep 17 00:00:00 2001 From: obadz Date: Sun, 29 Nov 2015 00:18:59 +0000 Subject: lightdm & xserver service: add ability to spawn more than one X server - if xserver.tty and/or display are set to null, then don't specify them, or the -logfile argument in the xserverArgs - For lightdm, we set default tty and display to null and we determine those at runtime based on arguments passed. This is necessary because we run multiple X servers so they can't all be on the same display --- nixos/modules/services/x11/display-managers/default.nix | 2 +- nixos/modules/services/x11/display-managers/lightdm.nix | 15 +++++++++++---- nixos/modules/services/x11/xserver.nix | 11 ++++++----- 3 files changed, 18 insertions(+), 10 deletions(-) (limited to 'nixos/modules/services/x11/display-managers') diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix index ca0832e5b0c8..bad99ccd8696 100644 --- a/nixos/modules/services/x11/display-managers/default.nix +++ b/nixos/modules/services/x11/display-managers/default.nix @@ -37,7 +37,7 @@ let # file provided by services.xserver.displayManager.session.script xsession = wm: dm: pkgs.writeScript "xsession" '' - #! /bin/sh + #! ${pkgs.bash}/bin/bash . /etc/profile cd "$HOME" diff --git a/nixos/modules/services/x11/display-managers/lightdm.nix b/nixos/modules/services/x11/display-managers/lightdm.nix index c8ccf43029dc..ded694d90d50 100644 --- a/nixos/modules/services/x11/display-managers/lightdm.nix +++ b/nixos/modules/services/x11/display-managers/lightdm.nix @@ -13,9 +13,16 @@ let # lightdm runs with clearenv(), but we need a few things in the enviornment for X to startup xserverWrapper = writeScript "xserver-wrapper" '' - #! /bin/sh + #! ${pkgs.bash}/bin/bash ${concatMapStrings (n: "export ${n}=\"${getAttr n xEnv}\"\n") (attrNames xEnv)} - exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs} + + display=$(echo "$@" | xargs -n 1 | grep -P ^:\\d\$ | head -n 1 | sed s/^://) + if [ -z "$display" ] + then additionalArgs=":0 -logfile /var/log/X.0.log" + else additionalArgs="-logfile /var/log/X.$display.log" + fi + + exec ${dmcfg.xserverBin} ${dmcfg.xserverArgs} $additionalArgs "$@" ''; usersConf = writeText "users.conf" @@ -39,7 +46,6 @@ let greeter-session = ${cfg.greeter.name} ${cfg.extraSeatDefaults} ''; - in { # Note: the order in which lightdm greeter modules are imported @@ -98,7 +104,6 @@ in }; config = mkIf cfg.enable { - services.xserver.displayManager.slim.enable = false; services.xserver.displayManager.job = { @@ -149,5 +154,7 @@ in services.xserver.displayManager.lightdm.background = mkDefault "${pkgs.nixos-artwork}/share/artwork/gnome/Gnome_Dark.png"; + services.xserver.tty = null; # We might start multiple X servers so let the tty increment themselves.. + services.xserver.display = null; # We specify our own display (and logfile) in xserver-wrapper up there }; } diff --git a/nixos/modules/services/x11/xserver.nix b/nixos/modules/services/x11/xserver.nix index 3348e8d0582c..8fcca70bc796 100644 --- a/nixos/modules/services/x11/xserver.nix +++ b/nixos/modules/services/x11/xserver.nix @@ -381,13 +381,13 @@ in }; tty = mkOption { - type = types.int; + type = types.nullOr types.int; default = 7; description = "Virtual console for the X server."; }; display = mkOption { - type = types.int; + type = types.nullOr types.int; default = 0; description = "Display number for the X server."; }; @@ -517,11 +517,12 @@ in services.xserver.displayManager.xserverArgs = [ "-ac" "-terminate" - "-logfile" "/var/log/X.${toString cfg.display}.log" "-config ${configFile}" - ":${toString cfg.display}" "vt${toString cfg.tty}" "-xkbdir" "${pkgs.xkeyboard_config}/etc/X11/xkb" - ] ++ optional (!cfg.enableTCP) "-nolisten tcp"; + ] ++ optional (cfg.display != null) ":${tostring cfg.display}" + ++ optional (cfg.tty != null) "vt${toString cfg.tty}" + ++ optional (cfg.display != null) [ "-logfile" "/var/log/X.${toString cfg.display}.log" ] + ++ optional (!cfg.enableTCP) "-nolisten tcp"; services.xserver.modules = concatLists (catAttrs "modules" cfg.drivers) ++ -- cgit 1.4.1