Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displayManager, windowManager, desktopManager: use extensible option types #20271

Closed
wants to merge 8 commits into from
5 changes: 2 additions & 3 deletions nixos/doc/manual/configuration/modularity.xml
Expand Up @@ -35,9 +35,8 @@ latter might look like this:
<programlisting>
{ config, pkgs, ... }:

{ services.xserver.enable = true;
services.xserver.displayManager.sddm.enable = true;
services.xserver.desktopManager.plasma5.enable = true;
{
services.xserver.desktopManager.select = [ "plasma5" ];
}
</programlisting>

Expand Down
32 changes: 21 additions & 11 deletions nixos/doc/manual/configuration/x-windows.xml
Expand Up @@ -25,23 +25,33 @@ Otherwise, you can only log into a plain undecorated
<command>xterm</command> window. Thus you should pick one or more of
the following lines:
<programlisting>
services.xserver.desktopManager.plasma5.enable = true;
services.xserver.desktopManager.xfce.enable = true;
services.xserver.desktopManager.gnome3.enable = true;
services.xserver.windowManager.xmonad.enable = true;
services.xserver.windowManager.twm.enable = true;
services.xserver.windowManager.icewm.enable = true;
services.xserver.windowManager.i3.enable = true;
services.xserver.desktopManager.select = [ "plasma5" ];
services.xserver.desktopManager.select = [ "xfce" ];
services.xserver.desktopManager.select = [ "gnome3" ];
services.xserver.windowManager.select = [ "xmonad" ];
services.xserver.windowManager.select = [ "twm" ];
services.xserver.windowManager.select = [ "icewm" ];
services.xserver.windowManager.select = [ "i3" ];
</programlisting>
</para>

<note><para>It is possible to use more than one window manager or desktop
manager at the same time by adding items to the list. In this case, the
first item of the list will become the default window manager or desktop
manager.
<programlisting>
services.xserver.desktopManager.select = [ "plasma5" "xfce" ];
services.xserver.windowManager.select = [ "xmonad" "i3" ];
</programlisting>
</para></note>

<para>NixOS’s default <emphasis>display manager</emphasis> (the
program that provides a graphical login prompt and manages the X
server) is SLiM. You can select an alternative one by picking one
of the following lines:
server) depends on the selected desktop manager or window manager.
You can select an alternative one by picking one of the following lines:
<programlisting>
services.xserver.displayManager.sddm.enable = true;
services.xserver.displayManager.lightdm.enable = true;
services.xserver.displayManager.select = "sddm";
services.xserver.displayManager.select = "lightdm";
</programlisting>
</para>

Expand Down
9 changes: 3 additions & 6 deletions nixos/doc/manual/configuration/xfce.xml
Expand Up @@ -9,10 +9,7 @@
<para>
To enable the Xfce Desktop Environment, set
<programlisting>
services.xserver.desktopManager = {
xfce.enable = true;
default = "xfce";
};
services.xserver.desktopManager.select = [ "xfce" ];
</programlisting>
</para>

Expand Down Expand Up @@ -43,7 +40,7 @@ services.compton = {
You can, for example, select KDE’s
<command>sddm</command> instead:
<programlisting>
services.xserver.displayManager.sddm.enable = true;
services.xserver.displayManager.select = "sddm";
</programlisting>
</para>

Expand All @@ -55,7 +52,7 @@ services.xserver.displayManager.sddm.enable = true;
<emphasis>Thunar</emphasis>
volume support, put
<programlisting>
services.xserver.desktopManager.xfce.enable = true;
services.xserver.desktopManager.select = [ "xfce" ];
</programlisting>
into your <emphasis>configuration.nix</emphasis>.
</para>
Expand Down
50 changes: 50 additions & 0 deletions nixos/doc/manual/release-notes/rl-1709.xml
Expand Up @@ -89,6 +89,56 @@ rmdir /var/lib/ipfs/.ipfs
The <literal>postgres</literal> default <literal>dataDir</literal> has changed from <literal>/var/db/postgres</literal> to <literal>/var/lib/postgresql/$psqlSchema</literal> where $psqlSchema is 9.6 for example.
</para>
</listitem>
<listitem>
<para>
The X server configuration interface changed, especially <literal>services.xserver.displayManager.*.enable</literal>,
<literal>services.xserver.windowManager.*.enable</literal> and <literal>services.xserver.desktopManager.*.enable</literal> options.
The <literal>services.xserver.desktopManager.default</literal> and <literal>services.xserver.windowManager.default</literal> have also
been removed.
</para>
<para>
<literal>services.xserver.displayManager.*.enable</literal> option was moved to <literal>services.xserver.displayManager.select</literal>
that has the <literal>nullOr enum</literal> type. The value of <literal>services.xserver.displayManager.select</literal> should be the name
of the used display manager. For example a configuration that was using:
<programlisting>
services.xserver.displayManager.lightdm.enable = true;
</programlisting>
Should be changed to:
<programlisting>
services.xserver.displayManager.select = "lightdm";
</programlisting>
Note: In case a desktop manager or a window manager is enabled, setting <literal>services.xserver.displayManager.select</literal>
is optional. If it is not explicitely set, its value will be set accordingly to the default window or desktop manager.
</para>
<para>
<literal>services.xserver.windowManager.*.enable</literal> option was moved to <literal>services.xserver.windowManager.select</literal>
that has the <literal>listOf enum</literal> type. The value of <literal>services.xserver.displayManager.select</literal> should be set to a
list of the used window managers names. For example a configuration that was using:
<programlisting>
services.xserver.windowManager.i3.enable = true;
</programlisting>
Should be changed to:
<programlisting>
services.xserver.windowManager.select = [ "i3" ];
</programlisting>
Note: This option is a list because it is possible to enable multiple window managers at the same time.
If multiple window managers are set, the first in the list will become the default one.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, there no ordering of elements guaranteed in NixOS, as the result of a merge can be whatever.
If the following 2 modules are merged, you have no idea how that are going to be merged.

{ services.xserver.desktopManager.select = [ "plasma5" ]; }
{ services.xserver.desktopManager.select = [ "gnome3" ]; }

Previously we had mkOrder properties with mkBefore and mkAfter, but these got replaced by a TODO in modules.nix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which TODO are you refering to? I have tested with a simple example and it seem that mkOrder is working as expected, but I might be missing something.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, only a sub-part of mkOrder is not implemented, which is a debatable part, about pushing down the ordering property. Honestly, as opposed to mkIf and mkOverride it might be debatable to support mkOrder on an attribute set which is not an option definition, so I will add an assertion and see if people can come with a use-case which where this might matter.

</para>
<para>
<literal>services.xserver.desktopManager.*.enable</literal> option was moved to <literal>services.xserver.desktopManager.select</literal>
that has the <literal>listOf enum</literal> type. The value of <literal>services.xserver.desktopManager.select</literal> should be set to a
list of the used desktop managers names. For example a configuration that was using:
<programlisting>
services.xserver.desktopManager.plasma5.enable = true;
</programlisting>
Should be changed to:
<programlisting>
services.xserver.desktopManager.select = [ "plasma5" ];
</programlisting>
Note: This option is a list because it is possible to enable multiple desktop managers at the same time.
If multiple desktop managers are set, the first in the list will become the default one.
</para>
</listitem>
</itemizedlist>


Expand Down
7 changes: 2 additions & 5 deletions nixos/lib/testing.nix
Expand Up @@ -209,11 +209,8 @@ rec {
inherit require;
virtualisation.memorySize = 1024;
services.xserver.enable = true;
services.xserver.displayManager.slim.enable = false;
services.xserver.displayManager.auto.enable = true;
services.xserver.windowManager.default = "icewm";
services.xserver.windowManager.icewm.enable = true;
services.xserver.desktopManager.default = "none";
services.xserver.displayManager.select = "auto";
services.xserver.windowManager.select = [ "icewm" ];
};
in
runInMachine ({
Expand Down
Expand Up @@ -11,13 +11,13 @@ with lib;
services.xserver = {
enable = true;
# GDM doesn't start in virtual machines with ISO
displayManager.select = "slim";
displayManager.slim = {
enable = true;
defaultUser = "root";
autoLogin = true;
};
desktopManager.select = [ "gnome3" ];
desktopManager.gnome3 = {
enable = true;
extraGSettingsOverrides = ''
[org.gnome.desktop.background]
show-desktop-icons=true
Expand Down
Expand Up @@ -18,8 +18,8 @@ with lib;
autoLogin = true;
};

desktopManager.select = [ "plasma5" ];
desktopManager.plasma5 = {
enable = true;
enableQt4Support = false;
};

Expand Down
3 changes: 1 addition & 2 deletions nixos/modules/installer/tools/nixos-generate-config.pl
Expand Up @@ -606,8 +606,7 @@ sub multiLineList {
# services.xserver.xkbOptions = "eurosign:e";

# Enable the KDE Desktop Environment.
# services.xserver.displayManager.sddm.enable = true;
# services.xserver.desktopManager.plasma5.enable = true;
# services.xserver.desktopManager.select = [ "plasma5" ];

# Define a user account. Don't forget to set a password with ‘passwd’.
# users.extraUsers.guest = {
Expand Down
33 changes: 31 additions & 2 deletions nixos/modules/module-list.nix
Expand Up @@ -598,6 +598,15 @@
./services/x11/unclutter.nix
./services/x11/unclutter-xfixes.nix
./services/x11/desktop-managers/default.nix
./services/x11/desktop-managers/enlightenment.nix
./services/x11/desktop-managers/gnome3.nix
./services/x11/desktop-managers/kodi.nix
./services/x11/desktop-managers/lumina.nix
./services/x11/desktop-managers/lxqt.nix
./services/x11/desktop-managers/none.nix
./services/x11/desktop-managers/plasma5.nix
./services/x11/desktop-managers/xfce.nix
./services/x11/desktop-managers/xterm.nix
./services/x11/display-managers/auto.nix
./services/x11/display-managers/default.nix
./services/x11/display-managers/gdm.nix
Expand All @@ -611,16 +620,36 @@
./services/x11/hardware/wacom.nix
./services/x11/redshift.nix
./services/x11/urxvtd.nix
./services/x11/window-managers/2bwm.nix
./services/x11/window-managers/afterstep.nix
./services/x11/window-managers/awesome.nix
#./services/x11/window-managers/compiz.nix
./services/x11/window-managers/bspwm.nix
./services/x11/window-managers/clfswm.nix
./services/x11/window-managers/compiz.nix
./services/x11/window-managers/default.nix
./services/x11/window-managers/dwm.nix
./services/x11/window-managers/exwm.nix
./services/x11/window-managers/fluxbox.nix
./services/x11/window-managers/fvwm.nix
./services/x11/window-managers/herbstluftwm.nix
./services/x11/window-managers/i3.nix
./services/x11/window-managers/icewm.nix
./services/x11/window-managers/bspwm.nix
./services/x11/window-managers/jwm.nix
./services/x11/window-managers/metacity.nix
./services/x11/window-managers/mwm.nix
./services/x11/window-managers/none.nix
./services/x11/window-managers/notion.nix
./services/x11/window-managers/openbox.nix
./services/x11/window-managers/oroborus.nix
./services/x11/window-managers/pekwm.nix
./services/x11/window-managers/qtile.nix
./services/x11/window-managers/ratpoison.nix
./services/x11/window-managers/sawfish.nix
./services/x11/window-managers/spectrwm.nix
./services/x11/window-managers/stumpwm.nix
./services/x11/window-managers/twm.nix
./services/x11/window-managers/windowlab.nix
./services/x11/window-managers/windowmaker.nix
./services/x11/window-managers/wmii.nix
./services/x11/window-managers/xmonad.nix
./services/x11/xautolock.nix
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/profiles/graphical.nix
Expand Up @@ -6,8 +6,8 @@
{
services.xserver = {
enable = true;
displayManager.sddm.enable = true;
desktopManager.plasma5.enable = true;
displayManager.select = "sddm";
desktopManager.select = [ "plasma5" ];
synaptics.enable = true; # for touchpad support on many laptops
};

Expand Down
3 changes: 0 additions & 3 deletions nixos/modules/rename.nix
Expand Up @@ -108,9 +108,6 @@ with lib;

(mkRenamedOptionModule [ "services" "hostapd" "extraCfg" ] [ "services" "hostapd" "extraConfig" ])

# Enlightenment
(mkRenamedOptionModule [ "services" "xserver" "desktopManager" "e19" "enable" ] [ "services" "xserver" "desktopManager" "enlightenment" "enable" ])

# Iodine
(mkRenamedOptionModule [ "services" "iodined" "enable" ] [ "services" "iodine" "server" "enable" ])
(mkRenamedOptionModule [ "services" "iodined" "domain" ] [ "services" "iodine" "server" "domain" ])
Expand Down
53 changes: 26 additions & 27 deletions nixos/modules/services/x11/desktop-managers/default.nix
Expand Up @@ -14,18 +14,21 @@ let
in

{
# Note: the order in which desktop manager modules are imported here
# determines the default: later modules (if enabled) are preferred.
# E.g., if Plasma 5 is enabled, it supersedes xterm.
imports = [
./none.nix ./xterm.nix ./xfce.nix ./plasma5.nix ./lumina.nix
./lxqt.nix ./enlightenment.nix ./gnome3.nix ./kodi.nix
];

options = {

services.xserver.desktopManager = {

select = mkOption {
type = with types; listOf (enum [ ]);
default = [];
description = ''
Select which desktop manager to use.
Selecting a desktop manager will automatically enable the X server and a default display manager.
The First item in the list will be made the default window manager.
'';
};

wallpaper = {
mode = mkOption {
type = types.enum [ "center" "fill" "max" "scale" "tile" ];
Expand Down Expand Up @@ -84,26 +87,6 @@ in
};
};

default = mkOption {
type = types.str;
default = "";
example = "none";
description = "Default desktop manager loaded if none have been chosen.";
apply = defaultDM:
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.
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}
'';
};

};

};
Expand All @@ -113,4 +96,20 @@ in
environment.systemPackages =
mkIf cfg.session.needBGPackages [ pkgs.feh ]; # xsetroot via xserver.enable
};

imports = [
# backward compatibility for pre extensible option types
(mkMergedOptionModule
(map
(dm: [ "services" "xserver" "desktopManager" dm "enable" ])
[ "elightenment" "gnome3" "kodi" "lumina" "lxqt" "plasma5" "xfce" "xterm" ])
[ "services" "xserver" "desktopManager" "select" ]
(config:
filter (dm:
(getAttrFromPath [ "services" "xserver" "desktopManager" dm "enable" ] config) == true
) [ "elightenment" "gnome3" "kodi" "lumina" "lxqt" "plasma5" "xfce" "xterm" ]))

(mkRemovedOptionModule [ "services" "xserver" "desktopManager" "default" ]
"The default desktop manager is the first item of the services.xserver.desktopManager.select list.")
];
}
9 changes: 4 additions & 5 deletions nixos/modules/services/x11/desktop-managers/enlightenment.nix
Expand Up @@ -6,7 +6,7 @@ let

e = pkgs.enlightenment;
xcfg = config.services.xserver;
cfg = xcfg.desktopManager.enlightenment;
dmcfg = config.services.xserver.desktopManager;
GST_PLUGIN_PATH = lib.makeSearchPathOutput "lib" "lib/gstreamer-1.0" [
pkgs.gst_all_1.gst-plugins-base
pkgs.gst_all_1.gst-plugins-good
Expand All @@ -18,14 +18,13 @@ in
{
options = {

services.xserver.desktopManager.enlightenment.enable = mkOption {
default = false;
description = "Enable the Enlightenment desktop environment.";
services.xserver.desktopManager.select = mkOption {
type = with types; listOf (enum [ "enlightenment" ]);
};

};

config = mkIf (xcfg.enable && cfg.enable) {
config = mkIf (elem "enlightenment" dmcfg.select) {

environment.systemPackages = [
e.efl e.enlightenment
Expand Down