Skip to content

Commit

Permalink
nixos/displayManager: deprecate separate options for default wm/dm
Browse files Browse the repository at this point in the history
The upstream session files display managers use have no concept of sessions being composed from
desktop manager and window manager. To be able to set upstream session files as default
session, we need a single option. Having two different ways to set default session would be confusing,
though, so we decided to deprecate the old method.

We also created separate script for each session, just like we already had a separate desktop
file for each one, and started using displayManager.sessionPackages mechanism to make the
session handling more uniform.
  • Loading branch information
jtojnar committed Dec 15, 2019
1 parent 53ef29c commit 8dc5ff7
Show file tree
Hide file tree
Showing 20 changed files with 254 additions and 224 deletions.
3 changes: 1 addition & 2 deletions nixos/doc/manual/configuration/x-windows.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@
desktop environment. If you wanted no desktop environment and i3 as your your
window manager, you'd define:
<programlisting>
<xref linkend="opt-services.xserver.desktopManager.default"/> = "none";
<xref linkend="opt-services.xserver.windowManager.default"/> = "i3";
<xref linkend="opt-services.xserver.displayManager.defaultSession"/> = "none+i3";
</programlisting>
And, finally, to enable auto-login for a user <literal>johndoe</literal>:
<programlisting>
Expand Down
5 changes: 2 additions & 3 deletions nixos/doc/manual/configuration/xfce.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
<para>
To enable the Xfce Desktop Environment, set
<programlisting>
<link linkend="opt-services.xserver.desktopManager.default">services.xserver.desktopManager</link> = {
<link linkend="opt-services.xserver.desktopManager.xfce.enable">xfce.enable</link> = true;
<link linkend="opt-services.xserver.desktopManager.default">default</link> = "xfce";
<xref linkend="opt-services.xserver.desktopManager.xfce.enable" /> = true;
<xref linkend="opt-services.xserver.displayManager.defaultSession" /> = "xfce";
};
</programlisting>
</para>
Expand Down
13 changes: 13 additions & 0 deletions nixos/doc/manual/release-notes/rl-2003.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,19 @@
and adding a <option>--all</option> option which prints all options and their values.
</para>
</listitem>
<listitem>
<para>
<option>services.xserver.desktopManager.default</option> and <option>services.xserver.windowManager.default</option> options were replaced by a single <xref linkend="opt-services.xserver.displayManager.defaultSession"/> option to improve support for upstream session files. If you used something like:
<programlisting>
services.xserver.desktopManager.default = "xfce";
services.xserver.windowManager.default = "icewm";
</programlisting>
you should change it to:
<programlisting>
services.xserver.displayManager.defaultSession = "xfce+icewm";
</programlisting>
</para>
</listitem>
</itemizedlist>
</section>

Expand Down
3 changes: 1 addition & 2 deletions nixos/lib/testing-python.nix
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,8 @@ in rec {
virtualisation.memorySize = 1024;
services.xserver.enable = true;
services.xserver.displayManager.auto.enable = true;
services.xserver.windowManager.default = "icewm";
services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
services.xserver.desktopManager.default = "none";
};
in
runInMachine ({
Expand Down
3 changes: 1 addition & 2 deletions nixos/lib/testing.nix
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,8 @@ in rec {
virtualisation.memorySize = 1024;
services.xserver.enable = true;
services.xserver.displayManager.auto.enable = true;
services.xserver.windowManager.default = "icewm";
services.xserver.displayManager.defaultSession = "none+icewm";
services.xserver.windowManager.icewm.enable = true;
services.xserver.desktopManager.default = "none";
};
in
runInMachine ({
Expand Down
23 changes: 7 additions & 16 deletions nixos/modules/services/x11/desktop-managers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,14 @@ in
};

default = mkOption {
type = types.str;
default = "";
type = types.nullOr types.str;
default = null;
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}
'';
description = ''
<emphasis role="strong">Deprecated</emphasis>, please use <xref linkend="opt-services.xserver.displayManager.defaultSession"/> instead.
Default desktop manager loaded if none have been chosen.
'';
};

};
Expand Down
2 changes: 2 additions & 0 deletions nixos/modules/services/x11/desktop-managers/pantheon.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ in

services.xserver.displayManager.lightdm.greeters.pantheon.enable = mkDefault true;

# Without this, Elementary LightDM greeter will pre-select non-existent `default` session
# https://github.com/elementary/greeter/issues/368
services.xserver.displayManager.defaultSession = "pantheon";

services.xserver.displayManager.sessionCommands = ''
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{ accountsservice
, glib
, gobject-introspection
, python3
, wrapGAppsHook
}:

python3.pkgs.buildPythonApplication {
name = "set-session";

format = "other";

src = ./set-session.py;

dontUnpack = true;

strictDeps = false;

nativeBuildInputs = [
wrapGAppsHook
gobject-introspection
];

buildInputs = [
accountsservice
glib
];

propagatedBuildInputs = with python3.pkgs; [
pygobject3
ordered-set
];

installPhase = ''
mkdir -p $out/bin
cp $src $out/bin/set-session
chmod +x $out/bin/set-session
'';
}
Loading

1 comment on commit 8dc5ff7

@nixos-discourse
Copy link

Choose a reason for hiding this comment

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

This commit has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-to-set-up-desktop-environment-per-user/6351/6

Please sign in to comment.