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

services.xserver: assert that either desktop- or window manager is not "none" #30517

Merged
merged 1 commit into from Nov 4, 2017

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Oct 17, 2017

Motivation for this change

setting a DM or WM is something I tend to forget when I want to built test machines with an X11 inside, so this assertion might catch unexpected behavior when building machines with X.

resolves #11064 (/cc @nbp )

I tested this against the following expressions:

{
  # VMs without X11 still evaluate
  empty = { pkgs, ... }: {
  };

  # needs to be commented out to avoid evaluation errors
  # no DM/WM set, should break
  onlyX11 = { pkgs, ... }: {
    services.xserver.enable = true;
  };

  # DM set, evaluates
  x11WithDM = { pkgs, ... }: {
    services.xserver = {
      enable = true;
      desktopManager.plasma5.enable = true;
      desktopManager.default = "plasma5";
    };
  };

  # WM set, evaluates
  x11WithWM = { pkgs, ... }: {
    services.xserver = {
      enable = true;
      windowManager.i3.enable = true;
      windowManager.default = "i3";
    };
  };

  # plain X sessions must be enabled explicitly
  x11Plain = { pkgs, ... }:{
    services.xserver.enable = true;
    services.xserver.plainX = true;
  };
}
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@rycee
Copy link
Member

rycee commented Oct 17, 2017

I'm not fond of this. Especially since it breaks my setup, which uses ~/.xsession. My complete services.xserver configuration for my laptop, including irrelevant stuff is

  services.xserver = {
    enable = true;
    layout = "us";
    displayManager.lightdm.enable = true;
    monitorSection = ''
      # Set the right DPI. Screen is 344x193 mm.
      DisplaySize 344 193
    '';
    libinput.enable = true;
  };

@vyp
Copy link
Member

vyp commented Oct 17, 2017

But what if we just want to use a plain X session?

@Ma27
Copy link
Member Author

Ma27 commented Oct 18, 2017

interesting, didn't know there are people using X without a DM or a WM. Just out of interest: what's the reason for a plain X session?

@rycee
Copy link
Member

rycee commented Oct 18, 2017

I'm using Home Manager to manage my X session. It mainly uses systemd user services started from ~/.xsession.

@vyp
Copy link
Member

vyp commented Oct 18, 2017

@Ma27 I'm not using without a DM/WM, but I find it quite useful as a debug step sometimes to figure out if an issue is due to the window manager, or say a regression in X sometimes (and obviously knowing that can save a lot of time). Also helps with debugging say a video driver with not so good linux kernel support, since you can rule out potential effects of DM/WM. (And the NixOS generations feature makes this easy to test as well.) I'm not opposed to say some configuration option that allows this, since my use case is admittedly rare, I just don't want it to be impossible. Edit: That way, the user has explicitly made clear that they know what they're doing. And maybe the evaluation error could also mention that you would need to set an option for this, somehow?

@Ma27
Copy link
Member Author

Ma27 commented Oct 22, 2017

@vyp @rycee thanks a lot for your explanations.

I'm not opposed to say some configuration option that allows this

so you mean a configuration option like services.xserver.plain which defaults to false and needs to be set to true explicitly?

@vyp
Copy link
Member

vyp commented Oct 22, 2017

so you mean a configuration option like services.xserver.plain which defaults to false and needs to be set to true explicitly?

Yep 👍

@Ma27
Copy link
Member Author

Ma27 commented Oct 23, 2017

@rycee if you're fine with this, I'd implement that additional option.

If not, I'd consider closing this for now :-)

@Ma27 Ma27 force-pushed the x11/assert-that-either-dm-or-wm-is-not-none branch from bb38700 to 59ff939 Compare October 23, 2017 10:24
@Ma27
Copy link
Member Author

Ma27 commented Oct 23, 2017

@vyp just found some time to implement this. Would you mind having a look at the change to confirm that this is a better solution? :)

@rycee
Copy link
Member

rycee commented Oct 23, 2017

Yeah, I think this is a decent compromise. I would prefer a name more along the lines of allowXSessionFile or allowXSessionOverride but it doesn't really matter.

@vyp
Copy link
Member

vyp commented Oct 23, 2017

@Ma27 unfortunately am really busy (time-sensitive) for at least a few days so afraid not right now. :/ (only just have time for making short responses from my phone when traveling tbh, if you're curious)

@Ma27 Ma27 force-pushed the x11/assert-that-either-dm-or-wm-is-not-none branch from 59ff939 to 2ae8633 Compare October 23, 2017 17:07
@Ma27
Copy link
Member Author

Ma27 commented Oct 23, 2017

rebased onto latest master which should fix the build.

Yeah, I think this is a decent compromise. I would prefer a name more along the lines of allowXSessionFile or allowXSessionOverride but it doesn't really matter.

I don't like this as setting a DM/WM doesn't prohibit overriding the XSession file. The only reason why this option exists is to "tell" Nix whether plain X sessions without a DM/WM are allowed.

(only just have time for making short responses from my phone when traveling tbh, if you're curious)

ok, I'll try to summarize it for you: I added an option services.xserver.plainX (default=false) which allows to set neither a WM nor a DM if true.

@rycee
Copy link
Member

rycee commented Nov 1, 2017

I'm fine with this. But I am thinking that it warrants a release note since it is a change that will break some people's installs. In particular, it should be clear what steps you need to take (enable services.xserver.plainX) to get things working again.

@Ma27
Copy link
Member Author

Ma27 commented Nov 1, 2017

makes sense, will add this :-)

@Ma27 Ma27 force-pushed the x11/assert-that-either-dm-or-wm-is-not-none branch from 2ae8633 to 86625cd Compare November 1, 2017 22:35
@Ma27 Ma27 requested a review from nbp as a code owner November 1, 2017 22:35
@Ma27
Copy link
Member Author

Ma27 commented Nov 1, 2017

@rycee done :-)

@rycee
Copy link
Member

rycee commented Nov 1, 2017

Thanks!

type = types.bool;
default = false;
description = ''
Whether the X11 session can be plain (without DM/WM) or not.
Copy link
Member

Choose a reason for hiding this comment

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

This description should explain that the Xsession is then used as a fallback.

@Ma27
Copy link
Member Author

Ma27 commented Nov 2, 2017

@nbp done :-)

@@ -552,6 +561,9 @@ in
+ "${toString (length primaryHeads)} heads set to primary: "
+ concatMapStringsSep ", " (x: x.output) primaryHeads;
})
{ assertion = cfg.desktopManager.default == "none" && cfg.windowManager.default == "none" -> cfg.plainX;
message = "Either the desktop manager or the window manager shouldn't be `none`!";
Copy link
Member

Choose a reason for hiding this comment

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

The best error message is the error message which let you fix the issue which is being reported.
This message should include some hint to fix the configuration.

Copy link
Member Author

Choose a reason for hiding this comment

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

agreed. Added another sentence which mentions the plainX option ...

@Ma27 Ma27 force-pushed the x11/assert-that-either-dm-or-wm-is-not-none branch from c2388e0 to 2752358 Compare November 2, 2017 20:49
@nbp nbp merged commit 93c54ac into NixOS:master Nov 4, 2017
@Ma27 Ma27 deleted the x11/assert-that-either-dm-or-wm-is-not-none branch November 4, 2017 14:35
@NeQuissimus
Copy link
Member

hmm, I am quite unhappy with this (since my rebuild just broke)
If I enable only a single windowmanager (i.e. xmonad), why would I need to explicitly define default = "xmonad"?

Some sort of default should be figured out automatically.
Can we give the modules something like default = mkDefault "xmonad"; ?

@Ma27
Copy link
Member Author

Ma27 commented Nov 4, 2017

I'm not 100% sure what you mean, sorry.
Could you please share the relevant parts of you config? :-)

@NeQuissimus
Copy link
Member

This is what I do to add XMonad to any config of mine:
https://github.com/NeQuissimus/DevSetup/blob/master/nixos-xmonad.nix#L42

I am already defining that I want to enable xmonad. Why should I have to add it again to "default"?

@Ma27
Copy link
Member Author

Ma27 commented Nov 4, 2017

I added an option services.xserver.plainX to explicitly allow this.

Can we give the modules something like default = mkDefault "xmonad"; ?

Sounds good, will think about this, however my I'm not sure how many time I'll have for this in the next days...

@nbp
Copy link
Member

nbp commented Nov 4, 2017

How is that possible to have both default to none, when there is one window manager enabled? I thought this code used to pick the only active element as the default.

I guess we should back it out, and figure out the issue with the default computation.

@Ma27
Copy link
Member Author

Ma27 commented Nov 4, 2017

enable a WM/DM != setting a default value.
I think that's why it has been suggested to set a default when enabling a WM/DM.

@nbp
Copy link
Member

nbp commented Nov 4, 2017

I think the default should be the only enabled WM/DM if any, and otherwise be the first one, or none if multiple.

@Ma27
Copy link
Member Author

Ma27 commented Nov 4, 2017

makes sense, will open a PR in the next days for that...

bendlas added a commit that referenced this pull request Nov 5, 2017
…er is not "none""

This reverts commit 93c54ac.
This reopens #30517 @nbp @Ma27

Breaking people's config for this is hardly reasonable as is. If it
absolutely cannot be avoided, at the very least, we need to provide
clear instructions on what people need to upgrade in their config. I
actually had to bisect to the commit, to even find out what property I
should change or define, as the error message was useless. It didn't
even mention a property name.

Discussion on the PR seems to be ongoing, so I'm reverting this, so we
don't break people's systems on unstable.
@Ma27 Ma27 mentioned this pull request Nov 5, 2017
8 tasks
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.

Assert when no window manager nor desktop manager are enabled.
6 participants