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

Conversation

ericsagnes
Copy link
Contributor

@ericsagnes ericsagnes commented Nov 9, 2016

Motivation for this change

Use extensible option types for xserver displayManager, windowManager and desktopManager options.
This should allow easier xserver configuration and modules.

  • displayManager
  • windowManager
  • desktopManager
  • All test passing
  • Documentation
  • Backward compatibility

Note: This PR content allow to setup Xserver by only setting required options, related options will automatically get adapted defaults. For example, to set plasma5 it was required to set the following:

{
  services.xserver.enable = true;
  services.xserver.displayManager.sddm.enable = true;
  services.xserver.desktopManager.plasma5.enable = true;
}

Now the following will have the same result:

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

Setting plasma5 as the desktop manager will automatically select sddm as display manager and enable the X server.

Note: The desktop managers and window managers are a list because it is possible to enable multiple at the same time. In that case the first entry in the list is considered as the default.

cc: @edolstra @nbp

@mention-bot
Copy link

@ericsagnes, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @abbradar and @ocharles to be potential reviewers.

@FRidh
Copy link
Member

FRidh commented Nov 9, 2016

I am not sure of the naming of the new option, displayManager.enable, as enable options are usually used with booleans.
There might be more appropriate option name, and suggestions are welcome!

available?

although we might have more display managers available but not enabled.

Edit: Nevermind, I mixed up display managers and window managers here.

@danbst
Copy link
Contributor

danbst commented Nov 9, 2016

maybe services.xserver.displayManager.selected = "kdm"; ?

@@ -11,7 +11,7 @@ import ./make-test.nix ({ pkgs, ...} : {

services.xserver.enable = true;

services.xserver.displayManager.auto.enable = true;
services.xserver.displayManager.enable = "auto"
Copy link
Member

Choose a reason for hiding this comment

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

Missed ;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, thank you!

@ericsagnes
Copy link
Contributor Author

ping @edolstra @nbp

Any thoughts on this, so far the list of propositions for this kind of option name are:

  • enable
  • enabled
  • select
  • selected
  • manager
  • managers
  • available

@ericsagnes
Copy link
Contributor Author

Update: fixed the conflicts.

@nbp
Copy link
Member

nbp commented May 26, 2017

@ericsagnes I guess the next step is to rewrite this code using extensible option declaration, with the enum type (#18380), correct?

@ericsagnes
Copy link
Contributor Author

@nbp I am not sure to understand, this PR is a rewrite of displayManager.*.enable options to use extensible option types (displayManager.enable with a nullOr enum).
For example: Main declaration, extended declaratations.

@nbp
Copy link
Member

nbp commented May 30, 2017

Ok, sorry I did a quick walkthrough and only noticed https://github.com/NixOS/nixpkgs/pull/20271/files#diff-05435704a2787433f3120047d8dc2b35R319 , which made me think that these were still the old changes. I will try to review it over the week-end.

@nbp nbp self-requested a review May 30, 2017 20:21
Copy link
Member

@nbp nbp left a comment

Choose a reason for hiding this comment

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

These changes looks good and succeeded where I failed to improve the module system in the past. This solve the uniqueness issue of the display manager, while providing a simple and nice interface for it.

On the other hand, the change to the auto display manager highlights one of the pitfall introduced by the uniqueness, which is that we would either have to repeat the config, or find another way to carry the result than the option which got used for the input. (see comments below)

@@ -126,7 +122,12 @@ in

###### implementation

config = mkIf cfg.enable {
config = mkIf (elem dmcfg.enable [ "slim" "auto" ]) {
Copy link
Member

Choose a reason for hiding this comment

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

It sounds like we do want to have a services.xserver.displayManager.slim.enabled (with an extra d) internal option, in order to make these abstraction modular.

In this case we want the auto display manager to be an alias for enabling the slim display manager as a back-end implementation while being added in the same unique list as slim. Having enabled option checks would allow us to work-around the uniqueness of the enum type.


services.xserver.displayManager.slim = {
autoLogin = mkIf (dmcfg.enable == "auto") true;
defaultUser = mkIf (dmcfg.enable == "auto") dmcfg.auto.user;
Copy link
Member

Choose a reason for hiding this comment

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

These definitions belong to the auto.nix file, which declares these options.

@@ -171,6 +171,15 @@ in

services.xserver.displayManager = {

enable = mkOption {
type = with types; nullOr (enum [ ]);
example = "slim";
Copy link
Member

Choose a reason for hiding this comment

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

you can move the example to the slim.nix file, if you prefer.

@@ -171,6 +171,15 @@ in

services.xserver.displayManager = {

enable = mkOption {
Copy link
Member

Choose a reason for hiding this comment

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

I think select makes more sense than any other name. enable is too much tied to a boolean value, while select clearly suppose a finite set of options. I would avoid the passive form here, as this is an input, and not a result.

@ericsagnes ericsagnes force-pushed the feat/dm-eot branch 2 times, most recently from 36466a6 to 991fd69 Compare June 1, 2017 12:52
@ericsagnes
Copy link
Contributor Author

Thanks for the detailed review and the precise advices, you are always very helpful!
I added the requested changes.

Next step is to use extended option types for desktopManagers and windowManagers to have a consistent xserver configuration.
As making a dedicated PR for each would result in some noise for unstable users, I propose to extend the scope of this PR so it contains desktopManager and windowManager too.

It will also make it easier to document the whole changes and check that all the tests are passing.

I will request another review when everything ready.

@ericsagnes ericsagnes changed the title display manager: use extensible option types [WIP] displayManager, windowManager, desktopManager: use extensible option types Jun 1, 2017
@ericsagnes ericsagnes force-pushed the feat/dm-eot branch 2 times, most recently from f2bcc97 to 5d197e9 Compare June 2, 2017 08:51
@ericsagnes ericsagnes changed the title [WIP] displayManager, windowManager, desktopManager: use extensible option types displayManager, windowManager, desktopManager: use extensible option types Jun 2, 2017
@ericsagnes
Copy link
Contributor Author

Added commits for desktop managers and window managers.

@nbp The PR is ready to review, could you please review it again when you have some time?


Passing the following tests, unchecked means failure:

  • test.gnome3
  • tests.gnome3-gdm
  • tests.i3wm
  • tests.plasma5
  • sddm.default
  • sddm.autoLogin
  • slim
  • xfce

gnome3-gdm was also failing on the latest nixos-unstable (http://hydra.nixos.org/build/53595717), so I suppose the failure reason is not related to this PR contents.

Copy link
Member

@nbp nbp left a comment

Choose a reason for hiding this comment

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

I admit I am not fond of the windowManagers.select and desktopManagers.select changes, as opposed to the displayManager.select option which expect a single result.

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.

@@ -205,6 +229,21 @@ in

services.xserver.displayManager = {

select = mkOption {
type = with types; nullOr (enum [ ]);
default = defaultDisplayManager;
Copy link
Member

Choose a reason for hiding this comment

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

Do not used computed values as default values.
If you want to do so, use the config section with mkDefault property.

The reason we should avoid this is because the documentation capture the default value, and adding this here would cause the documentation to not only depend on the option declarations, but also to depends on the option definitions.

Doing so used to recompile the documentation locally instead of downloading it. Today we use a work-around to avoid the recompilation, but this implies that we have to re-evaluate all NixOS modules a second time, which is far from ideal.

description = ''
Whether to enable SLiM as the display manager.
Option to abstract slim usage.
Copy link
Member

Choose a reason for hiding this comment

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

@ericsagnes
Copy link
Contributor Author

I admit I am not fond of the windowManagers.select and desktopManagers.select changes, as opposed to the displayManager.select option which expect a single result.

I do agree that it does not feel like the perfect solution, but still it is an improvement over the current desktopManager.*.enable and desktopManager.default combination that was requiring extra checks to verify the default desktop / window manager was enabled (and also checks in other modules).

I am open to change this approach to any better solution.

@nbp
Copy link
Member

nbp commented Jun 10, 2017

I hope that most NixOS user would never have to learn about mkIf, mkOverride, or mkOrder.

Thus, I am highly worried about the order of the window / desktop managers, as this is an option which is quite visible to new desktop users of NixOS. While I do not expect new users to split their modules them-self, I would still expect to have new users import someone else configuration.

Before, importing someone configuration would raise an error message about the fact that the option is defined twice. In this new case this would pick one at random.

I think it would be better to have each window / desktop manager define what is their default display manager with mkDefault, and raise an error if we do not have a uniquely preferred display manager as the result of the merge. Thus, a user having selected both KDE and Gnome would be prompted to select a display manager as there is no guessable default.

What do you think?

@alunduil
Copy link
Contributor

I see it's been a while since this was last commented on but the final suggestion where each configuration comes with a sensible default that I can override makes sense to me. Have we propositioned the community via IRC and discourse to gain more thoughts around this interface? Alternatively, has this work been abandoned and this pull request should be closed?

@stale
Copy link

stale bot commented Jun 1, 2020

Thank you for your contributions.
This has been automatically marked as stale because it has had no activity for 180 days.
If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.
Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the
    related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse. 3. Ask on the #nixos channel on
    irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 1, 2020
@domenkozar
Copy link
Member

This has changed in 20.03 and is incompatible with this PR.

@domenkozar domenkozar closed this Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants