diff --git a/modules/module-list.nix b/modules/module-list.nix index 537e6181469..f0a17bcd870 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -117,10 +117,6 @@ ./services/web-servers/jboss.nix ./services/web-servers/tomcat.nix ./services/x11/desktop-managers/default.nix - ./services/x11/desktop-managers/gnome.nix - ./services/x11/desktop-managers/kde4.nix - ./services/x11/desktop-managers/none.nix - ./services/x11/desktop-managers/xterm.nix ./services/x11/display-managers/default.nix ./services/x11/display-managers/auto.nix ./services/x11/display-managers/kdm.nix diff --git a/modules/services/x11/desktop-managers/default.nix b/modules/services/x11/desktop-managers/default.nix index 8afe14b743d..04fda6d2232 100644 --- a/modules/services/x11/desktop-managers/default.nix +++ b/modules/services/x11/desktop-managers/default.nix @@ -1,22 +1,23 @@ -{pkgs, config, ...}: +{ config, pkgs, ... }: + +with pkgs.lib; let - inherit (pkgs.lib) mkOption mergeOneOption mkIf filter optionalString any; + xcfg = config.services.xserver; cfg = xcfg.desktopManager; # Whether desktop manager `d' is capable of setting a background. # If it isn't, the `feh' program is used as a fallback. needBGCond = d: ! (d ? bgSupport && d.bgSupport); + in { - imports = [ - ./kde4.nix - ./gnome.nix - ./xterm.nix - ./none.nix - ]; + # Note: the order in which desktop manager modules are imported here + # determines the default: later modules (if enabled) are preferred. + # E.g., if KDE is enabled, it supersedes xterm. + imports = [ ./none.nix ./xterm.nix ./gnome.nix ./kde4.nix ]; options = { @@ -24,11 +25,11 @@ in session = mkOption { default = []; - example = [{ - name = "kde"; - bgSupport = true; - start = "..."; - }]; + example = singleton + { name = "kde"; + bgSupport = true; + start = "..."; + }; description = " Internal option used to add some common line to desktop manager scripts before forwarding the value to the @@ -48,16 +49,15 @@ in }; }; - default = mkOption { - default = "xterm"; + default = ""; example = "none"; - description = " - Default desktop manager loaded if none have been chosen. - "; + description = "Default desktop manager loaded if none have been chosen."; merge = mergeOneOption; apply = defaultDM: - if any (w: w.name == defaultDM) cfg.session.list then + if defaultDM == "" && cfg.session.list != [] then + (head cfg.session.list).name + else if any (w: w.name == defaultDM) cfg.session.list then defaultDM else throw "Default desktop manager ($(defaultDM)) not found."; diff --git a/modules/services/x11/display-managers/default.nix b/modules/services/x11/display-managers/default.nix index 197ba7631e9..d2b01a61ba8 100644 --- a/modules/services/x11/display-managers/default.nix +++ b/modules/services/x11/display-managers/default.nix @@ -23,7 +23,7 @@ let # The first argument of this script is the session type. sessionType="$1" - if test "$sessionType" = default; then sessionType=""; fi + if [ "$sessionType" = default ]; then sessionType=""; fi ${optionalString (!cfg.displayManager.job.logsXsession) '' exec > ~/.xsession-errors 2>&1 @@ -180,7 +180,9 @@ in apply = list: rec { wm = filter (s: s.manage == "window") list; dm = filter (s: s.manage == "desktop") list; - names = concatMap (d: map (w: d.name + " + " + w.name) wm) dm; + names = flip concatMap dm + (d: map (w: d.name + optionalString (w.name != "none") (" + " + w.name)) + (filter (w: d.name != "none" || w.name != "none") wm)); desktops = mkDesktops names; script = xsession wm dm; }; diff --git a/modules/services/x11/display-managers/kdm.nix b/modules/services/x11/display-managers/kdm.nix index 74b430e298c..7dd979376d6 100644 --- a/modules/services/x11/display-managers/kdm.nix +++ b/modules/services/x11/display-managers/kdm.nix @@ -26,6 +26,8 @@ let [X-:*-Core] ServerCmd=${dmcfg.xserverBin} ${dmcfg.xserverArgs} + # KDM calls `rm' somewhere to clean up some temporary directory. + SystemPath=${pkgs.coreutils}/bin # The default timeout (15) is too short in a heavily loaded boot process. ServerTimeout=60 # Needed to prevent the X server from dying on logout and not coming back: