summary refs log tree commit diff
path: root/nixos/modules
diff options
context:
space:
mode:
authorTor Hedin Brønner <torhedinbronner@gmail.com>2019-01-12 10:31:37 +0100
committerJan Tojnar <jtojnar@gmail.com>2019-12-15 04:16:20 +0100
commitd25365c3c13f2fcc4e5574f01106c061c493e63e (patch)
treedda982f84e63f48a3f46b71eb17747d77e6809a4 /nixos/modules
parent58e5290fcee60178973f4cc21011fbbf03497410 (diff)
downloadnixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.tar
nixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.tar.gz
nixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.tar.bz2
nixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.tar.lz
nixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.tar.xz
nixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.tar.zst
nixpkgs-d25365c3c13f2fcc4e5574f01106c061c493e63e.zip
nixos/displayManager: introduce defaultSession
There's two ways of providing graphical sessions now:
- `displayManager.session` via. `desktopManager.session` and
  `windowManager.session`
- `displayManager.sessionPackages`

`sessionPackages` doesn't make a distinction between desktop and window
managers. This makes selecting a session provided by a package using
`desktopManager.default` nonsensical.

We therefor introduce `displayManager.defaultSession` which can select a session
from either `displayManager.session` or `displayManager.sessionPackages`.

It will default to `desktopManager.default + windowManager.default` as before.
If the dm default is "none" it will select the first provided session from
`sessionPackages`.
Diffstat (limited to 'nixos/modules')
-rw-r--r--nixos/modules/services/x11/desktop-managers/default.nix12
-rw-r--r--nixos/modules/services/x11/desktop-managers/pantheon.nix4
-rw-r--r--nixos/modules/services/x11/display-managers/default.nix31
-rw-r--r--nixos/modules/services/x11/display-managers/lightdm.nix8
-rw-r--r--nixos/modules/services/x11/display-managers/sddm.nix8
5 files changed, 43 insertions, 20 deletions
diff --git a/nixos/modules/services/x11/desktop-managers/default.nix b/nixos/modules/services/x11/desktop-managers/default.nix
index ed2b09cb21c..7240358c361 100644
--- a/nixos/modules/services/x11/desktop-managers/default.nix
+++ b/nixos/modules/services/x11/desktop-managers/default.nix
@@ -96,13 +96,13 @@ in
           else if any (w: w.name == defaultDM) cfg.session.list then
             defaultDM
           else
-            builtins.trace ''
-              Default desktop manager (${defaultDM}) not found at evaluation time.
-              These are the known valid session names:
+            throw ''
+              Default desktop manager (${defaultDM}) not found.
+              Probably you want to change
+                services.xserver.desktopManager.default = "${defaultDM}";
+              to one of
                 ${concatMapStringsSep "\n  " (w: "services.xserver.desktopManager.default = \"${w.name}\";") cfg.session.list}
-              It's also possible the default can be found in one of these packages:
-                ${concatMapStringsSep "\n  " (p: p.name) config.services.xserver.displayManager.sessionPackages}
-            '' defaultDM;
+            '';
       };
 
     };
diff --git a/nixos/modules/services/x11/desktop-managers/pantheon.nix b/nixos/modules/services/x11/desktop-managers/pantheon.nix
index 614f4638cf5..3722bf365ba 100644
--- a/nixos/modules/services/x11/desktop-managers/pantheon.nix
+++ b/nixos/modules/services/x11/desktop-managers/pantheon.nix
@@ -81,9 +81,7 @@ in
 
     services.xserver.displayManager.lightdm.greeters.pantheon.enable = mkDefault true;
 
-    # If not set manually Pantheon session cannot be started
-    # Known issue of https://github.com/NixOS/nixpkgs/pull/43992
-    services.xserver.desktopManager.default = mkForce "pantheon";
+    services.xserver.displayManager.defaultSession = "pantheon";
 
     services.xserver.displayManager.sessionCommands = ''
       if test "$XDG_CURRENT_DESKTOP" = "Pantheon"; then
diff --git a/nixos/modules/services/x11/display-managers/default.nix b/nixos/modules/services/x11/display-managers/default.nix
index f55bfbfd0c1..1a46e7c02e5 100644
--- a/nixos/modules/services/x11/display-managers/default.nix
+++ b/nixos/modules/services/x11/display-managers/default.nix
@@ -327,6 +327,37 @@ in
         };
       };
 
+      defaultSession = mkOption {
+        type = with types; str // {
+          description = "session name";
+          check = d: let
+            sessionNames = cfg.displayManager.session.names ++
+              (concatMap (p: p.providedSessions) cfg.displayManager.sessionPackages);
+          in
+            assertMsg (str.check d && (d == "none" || (elem d sessionNames))) ''
+                Default graphical session, '${d}', not found.
+                Valid names for 'services.xserver.displayManager.defaultSession' are:
+                  ${concatStringsSep "\n  " sessionNames}
+              '';
+        };
+        default = let
+            dmDefault = cfg.desktopManager.default;
+            wmDefault = cfg.windowManager.default;
+            defaultPackage =
+              if cfg.displayManager.sessionPackages != [] then
+                (head (head cfg.displayManager.sessionPackages).providedSessions)
+              else
+                null;
+            defaultDmWm = dmDefault + optionalString (wmDefault != "none") ("+" + wmDefault);
+          in
+            if defaultDmWm == "none" && isString defaultPackage then
+              defaultPackage
+            else
+              defaultDmWm;
+        example = "gnome";
+        description = "Default graphical session (only effective for LightDM and SDDM).";
+      };
+
       job = {
 
         preStart = mkOption {
diff --git a/nixos/modules/services/x11/display-managers/lightdm.nix b/nixos/modules/services/x11/display-managers/lightdm.nix
index cf4c05acbcc..71cd6079ea1 100644
--- a/nixos/modules/services/x11/display-managers/lightdm.nix
+++ b/nixos/modules/services/x11/display-managers/lightdm.nix
@@ -9,9 +9,8 @@ let
   xEnv = config.systemd.services.display-manager.environment;
   cfg = dmcfg.lightdm;
 
-  dmDefault = xcfg.desktopManager.default;
-  wmDefault = xcfg.windowManager.default;
-  hasDefaultUserSession = dmDefault != "none" || wmDefault != "none";
+  defaultSessionName = dmcfg.defaultSession;
+  hasDefaultUserSession = defaultSessionName != "none";
 
   inherit (pkgs) lightdm writeScript writeText;
 
@@ -71,7 +70,6 @@ let
       ${cfg.extraSeatDefaults}
     '';
 
-  defaultSessionName = dmDefault + optionalString (wmDefault != "none") ("+" + wmDefault);
 in
 {
   # Note: the order in which lightdm greeter modules are imported
@@ -199,7 +197,7 @@ in
           LightDM auto-login requires services.xserver.displayManager.lightdm.autoLogin.user to be set
         '';
       }
-      { assertion = cfg.autoLogin.enable -> dmDefault != "none" || wmDefault != "none";
+      { assertion = cfg.autoLogin.enable -> hasDefaultUserSession;
         message = ''
           LightDM auto-login requires that services.xserver.desktopManager.default and
           services.xserver.windowManager.default are set to valid values. The current
diff --git a/nixos/modules/services/x11/display-managers/sddm.nix b/nixos/modules/services/x11/display-managers/sddm.nix
index 24e120c4f2c..b51582d2ca5 100644
--- a/nixos/modules/services/x11/display-managers/sddm.nix
+++ b/nixos/modules/services/x11/display-managers/sddm.nix
@@ -71,11 +71,7 @@ let
     ${cfg.extraConfig}
   '';
 
-  defaultSessionName =
-    let
-      dm = xcfg.desktopManager.default;
-      wm = xcfg.windowManager.default;
-    in dm + optionalString (wm != "none") ("+" + wm);
+  defaultSessionName = dmcfg.defaultSession;
 
 in
 {
@@ -210,7 +206,7 @@ in
           SDDM auto-login requires services.xserver.displayManager.sddm.autoLogin.user to be set
         '';
       }
-      { assertion = cfg.autoLogin.enable -> elem defaultSessionName dmcfg.session.names;
+      { assertion = cfg.autoLogin.enable -> defaultSessionName != "none";
         message = ''
           SDDM auto-login requires that services.xserver.desktopManager.default and
           services.xserver.windowManager.default are set to valid values. The current