[WIP] display/desktop managers: change enable to enums#15096
[WIP] display/desktop managers: change enable to enums#15096ericsagnes wants to merge 2 commits intoNixOS:masterfrom
Conversation
|
+1. Nitpick: why is the option called "enabled" with a 'd'? Most NixOS options are called "enable" (no 'd'). |
|
Right, So in my understanding:
|
|
My interpretation is that enable vs enabled is only about time: present/future vs past. IOW, having some "enable" and some "enabled" options would just make it inconsistent. (English isn't my native language either.) |
|
@ericsagnes I agree with your interpretation: enable is a verb, enabled is a state, to my mind anyway. Not a big fan of "enabled", though, "manager" would be better, IMO, but still not perfect ... More importantly, I wonder whether itemizing the possibilities in the docstring is required, won't that duplicate information already present in the enum? |
|
I just picked a slightly different name to differentiate the option from the usual boolean
I agree, this is just noise and detailed information should be in |
|
I guess we can quibble over naming forever, so would be too bad if that were to hold this up, looks like an upgrade otherwise. "enabled" really doesn't make that much sense to me, but the docstring makes it clear enough, IMO. |
|
👍 on the change to 👎 on the change to |
|
@ttuegel Thanks for the feedback, that was something I was unaware of. For desktop managers, making the option type So the configuration would become something like: |
|
I'd drop the |
|
I updated the PR with a rough implementation, it still need some polishing and test but the few display/desktop/window manager related tests in There might need assertions to make the system work nicely for edge cases like when incompatible window managers and desktop managers are enabled together. This remove a fair amount of options and might break some configurations so it should be tested with So, the detail:
So for example to use xfce and kde and use xfce as the default session: To use i3 only: To use xmonad and slim: |
|
Nice! |
| ./services/x11/desktop-managers/none.nix | ||
| ./services/x11/desktop-managers/xfce.nix | ||
| ./services/x11/desktop-managers/xterm.nix | ||
| #./services/x11/display-managers/auto.nix |
There was a problem hiding this comment.
Can we drop the comment and also remove the file?
There was a problem hiding this comment.
@groxxda Thanks for the suggestion, I added a commit that remove the file and the comment.
|
On attribute names, I'd prefer something other than |
|
I'm ok with either attribute name and don't think this discussion should block the pr getting merged. Maybe |
|
I think "enabled" is a better choice because then we get consistency with |
|
Naming is always complicated, that is too bad we don't have maintainers for each module yet, it would have be best to let them decide. Does @edolstra and @nbp have any preference about how to name the kind of option that enable one or multiple choices in a list like this PR So far the propositions are:
|
|
I'm a bit "meh" about this PR, which introduces a fair bit of incompatibility for little gain (i.e. saving one line in configuration.nix). And arguably the choice of whether to enable the X server and which desktop managers to enable should be independent options. Another problem is that enums are not modular. For example, how can I extend the enumeration in An alternative is to have the desktop managers enable X11 and preferred display managers by default, e.g. KDE could do: |
|
Thanks for the feedback, I totally agree with the large incompatibilities and risks this PR brings, and at the moment I personally see it more as an experiment which the main point is to look for ways to be more user friendly. Regarding the little gain, it depends on the standing point I guess, for a normal xmonad setup the following is currently needed: The That is because the way
I think that at the moment this is not possible, but in the current implementation we also have non modular things like setting
Please correct me if wrong, but I think that this alternative will not work well if, for example, the user enable gnome and kde4 and each enable a different display manager as there can be only one display manager enabled. Anyway, I agree these are fair concerns that we should think when the PR is more mature to decide whether it is a real improvement and worth merging or not. By the way, do you have any preference on the option name mentioned in my previous comment? |
|
The reason I made the module system is because I had to modify NixOS sources to support my system. As a goal, I wanted to avoid modification of the NixOS sources to add any new displayManager, windowManager, desktopManager. Thus, I absolutely wanted to avoid having an enumeration of names, as having such enumeration is likely a hint that imply that one is not able to extend NixOS with a new displayManager, windowManager, or desktopManager. The way the list of window managers is made in the current set of patches ( https://github.com/ericsagnes/nixpkgs/blob/3d6c83aab2c11f5c2877b517b2a528e865d37c93/nixos/modules/services/x11/window-managers/default.nix#L43 ) is a limitation to the modularity. The reason why modularity is so important is that one can use and extend NixOS, without having to give away the ownership of the code they used to build their system, such as password, …, while having the simplicity of updating their systems, without rebasing patches. |
It totally make sense, but the current module system have also some un-modular parts.
But yes, the approach of this PR is not the right one. I wonder if something like extended option types could be implemented in the module system for such cases. For example, some pseudo-code in the window manager module: And in other module we extend the type, eg awesome module definition: And the values get merged according to the This way we could have modularity without dozens of possibly conflicting Do you think this could be added to the current module system? |
The order of imports is undefined, in the module system specification, as it can be cheated by importing the same module from else-where. If the order is important, then the
This should be guarded by assertions, which are suggesting how to fix things. Note that the module system cannot add modularity if the underlying program that it maps to does not support it. In such cases, assertions should prevent us from even generating configurations in such cases. The error would be to detect the error after a valid evaluation.
Note that today we can already extend option declaration with non-conflicting option declarations. The There is already a special case implemented for submodules modules. |
|
Thanks for the pointers! |
Work in progress
Example of what would it be to turn related
foo.enableoptions in oneenumoption.The code is just for demonstration purpose and not supposed to work or do anything else than breaking configurations at current time.
I just would like to gather feedback on this approach before doing a real implementation or abandoning it.
For example now to enable
kde4there is 3 settings to change:and as each
desktopManageroptions are unrelated it is possible to do things like:With this approach we can enable a desktop manager in one option:
The display manager will be set to the one fitting the desktop manager by default, but it is also possible to explicitly set one: