NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.36k stars 13.59k forks source link

lightdm-mini-greeter not starting none+bspwm session #108289

Open frogamic opened 3 years ago

frogamic commented 3 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior:

  1. Set up a brand new NixOS machine (might occur on existing machines too? this is just the context in which I found it)
  2. add the following to configuration.nix

    services.xserver = {
    enable = true;
    
    displayManager = {
    defaultSession = "none+bspwm";
    lightdm.greeters.mini = {
      enable = true;
      user = "dominic";
      extraConfig = ''
        [greeter]
        show-password-label = false
        invalid-password-text = Access Denied
        show-input-cursor = true
        password-alignment = left
        [greeter-theme]
        font-size = 1em
        background-image = ""
      '';
    };
    };
    
    windowManager.bspwm = {
    enable = true;
    configFile = "${./bspwmrc}";
    sxhkd.configFile = "${./sxhkdrc}";
    };
    };
  3. Restart display-manager.service
  4. Attempt to log in.

Expected behavior Lightdm-mini-greeter starts a none+bspwm session

Logs

/var/log/lightdm.conf:
...
[+0.77s] DEBUG: Greeter connected version=1.30.0 api=1 resettable=false
[+0.77s] DEBUG: Greeter start authentication for dominic
[+0.77s] DEBUG: Session pid=19028: Started with service 'lightdm', username 'dominic'
[+0.77s] DEBUG: Session pid=19028: Got 1 message(s) from PAM
[+0.77s] DEBUG: Prompt greeter with 1 message(s)
[+5.33s] DEBUG: Continue authentication
[+5.33s] DEBUG: Session pid=19028: Authentication complete with return value 0: Success
[+5.33s] DEBUG: Authenticate result for user dominic: Success
[+5.33s] DEBUG: User dominic authorized
[+5.33s] DEBUG: Greeter requests default session
[+5.33s] DEBUG: Seat seat0: Failed to find session configuration default
[+5.33s] DEBUG: Seat seat0: Can't find session 'default'
[+7.60s] DEBUG: Seat seat0 changes active session to 2

Additional context The same issue happened when trying xfce+bspwm too.

Notify maintainers @mnacamura @prikhi

Metadata the same was occuring under 20.09 too prior to switching to unstable channel.

 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.85, NixOS, 21.03pre260232.733e537a8ad (Okapi)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.10`
 - channels(root): `"nixos-21.03pre260232.733e537a8ad"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`
imatpot commented 3 years ago

I have the same issue on NixOS 20.09 but with lightdm-tiny-greeter

/var/log/lightdm/lightdm.log
...
[+0.61s] DEBUG: Greeter connected version=1.30.0 api=1 resettable=false
[+0.61s] DEBUG: Greeter start authentication
[+0.61s] DEBUG: Session pid=1003: Started with service 'lightdm', username '(null)'
[+0.62s] DEBUG: Session pid=1003: Got 1 message(s) from PAM
[+0.62s] DEBUG: Prompt greeter with 1 message(s)
[+2.92s] DEBUG: Continue authentication
[+2.92s] DEBUG: Session pid=1003: Got 1 message(s) from PAM
[+2.92s] DEBUG: Prompt greeter with 1 message(s)
[+4.13s] DEBUG: Continue authentication
[+4.14s] DEBUG: Session pid=1003: Authentication complete with return value 0: Success
[+4.14s] DEBUG: Authenticate result for user mladen: Success
[+4.14s] DEBUG: User mladen authorized
[+4.14s] DEBUG: Greeter requests session default
[+4.14s] DEBUG: Seat seat0: Failed to find session configuration default
[+4.14s] DEBUG: Seat seat0: Can't find session 'default'

with this config:

services.xserver = {
  displayManager = {
    defaultSession = "none+bspwm";
    lightdm.greeters.tiny.enable = true;
  };

  windowManager.bspwm = {
    enable = true;
    configFile = "${./bspwmrc}";
    sxhkd.configFile = "${./sxhkdrc}";
  };
};

However, other greeters - such as mini - actually do work properly and request the session none+bspwm. Relevant config is basically identical (except the greeter ofc):

services.xserver = {
  displayManager = {
    defaultSession = "none+bspwm";
    lightdm.greeters.mini = {
      enable = true;
      user = "mladen";
    };
  };

  windowManager.bspwm = {
    enable = true;
    configFile = "${./bspwmrc}";
    sxhkd.configFile = "${./sxhkdrc}";
  };
};

Metadata:

prikhi commented 3 years ago

What does a default session of none+bspwm mean?

mini-greeter(and I assume tiny-greeter) just uses lightdm's default-session functionality, which requires a matching XYZ.desktop file in /usr/share/xsessions/

frogamic commented 3 years ago

NixOS uses the notion of DE+WM from what I can tell (I started using it on graphical systems ~2 weeks ago), so you could have xfce+bspwm for example. In my case I was starting X for the first time so I had no ~/.dmrc referencing any session types. My /usr/share/xsessions/ folder did only contain one file none+bspwm.desktop.

It seems that this bug then is specific to first X startup, where the default session type as specified in services.xserver.displayManager.defaultSession is not correctly picked up by LightDM. I am not familiar with LightDM, but is there a way to specify the systemwide default if ~/.dmrc is not found?

frogamic commented 3 years ago

I just tested my theory, and after switching from lightdm-gtk-greeter back to lightdm-mini-greeter it works fine. However I do not have a ~/.dmrc file, so that cannot be what is causing it to know which session to start as default. I would be curious where this default session is being persisted by NixOS.

The canonical lightdm.conf indicates that this could be solved by adding user-session = ${services.xserver.displayManager.defaultSession} to the [Seat:*] section of the /etc/lightdm/lightdm.conf generated by NixOS. I am cautious that setting this in lightdm.conf could override another setting somewhere as I do not know how lightdm's config hierarchy works.

I have tested this on a VM and was able to reproduce the issue every time lightdm-mini-greeter was used as the first greeter for first x startup. Using services.xserver.displayManager.lightdm.extraSeatDefaults to set the default user-session did fix this, however that seems redundant and a fix in lightdm.nix would be preferable.

prikhi commented 3 years ago

this could be solved by adding user-session = ${services.xserver.displayManager.defaultSession}

Yes, setting this option is what mini-greeter expects you to do. This is what lightdm.nix used to do when mini-greeter was added: https://github.com/NixOS/nixpkgs/blob/6b9a99e55d537c27c5b384d58c997839a0519df9/nixos/modules/services/x11/display-managers/lightdm.nix

I believe anything in cfg.extraSeatDefaults will be able to override this but I'm not sure why it's been removed.

CC @mnacamura

frogamic commented 3 years ago

It looks like that was removed when separate window manager and desktop environment defaults were deprecated in favour of a single defaultSession: https://github.com/NixOS/nixpkgs/commit/8dc5ff7dcfd1c58c32004ffae25e6d31ed83d86c#diff-adb642202a7cc18b6bf16da112c9d39e95b5b576010cebbc3db2a7402a337066 CC @jtojnar

jtojnar commented 3 years ago

We do not set the default session in the config file any more, we replaced that in the same commit by a call to AccountsService:

https://github.com/NixOS/nixpkgs/commit/8dc5ff7dcfd1c58c32004ffae25e6d31ed83d86c#diff-adb642202a7cc18b6bf16da112c9d39e95b5b576010cebbc3db2a7402a337066R210-R214

I am not sure why it does not work for mini greeter.

I would guess it works after logging in with the gtk greeter because it will tell AccountsServer that user logged in into a certain session and the next time, the mini greeter will use the last used session it will obtain from AccountsService.

prikhi commented 3 years ago

Ah, at present, mini doesn't do any work w/ trying to find a session - it relies solely on the lightdm's default session functionality... Eventually I'd like to add session management if the user-session is not set, but for now should I just add something like this to the nixos section of the README?

services.xserver.displayManager.lightdm.extraSeatDefaults = ''
  user-session = awesome
''

Should I remove the bit that mentions setting windowManager.default = "awesome"?

jtojnar commented 3 years ago

You can also use the following:

  user-session = ${config.services.xserver.displayManager.defaultSession}

we could also do that in the NixOS module and assert that the default session is set like tiny greeter does.

Regarding the readme, note that services.xserver.windowManager.default = "awesome" is deprecated. It should be replaced by services.xserver.displayManager.defaultSession = "none+awesome".

That option is not strictly required – it is meant to set the pre-selected session in session chooser, which is done for GDM and LightDM using the AccountsService API.

If the mini greeter does not have a session chooser than it does not make sense to set the option (unless using autologin, since it uses the same option to force the autologin session).

So in the short term, I would propose adding the extra config in the mini NixOS module, and then later, make the greeter crawl $XDG_DATA_DIRS for .session files and choose one of them, instead of falling back to default session that might not exist.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

prikhi commented 3 years ago

Hi, don't really have time to look into this, sorry.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

tlpred commented 1 year ago

Hello, so the trick with extraSeatDefaults = ''user-session = ${config.services.xserver.displayManager.defaultSession}''; doesn't work anymore with tiny and slick greeters. It still logs "Cannot find session 'default'" to logs.

To fight this issue now you need to explicitly create a session, named "default".

services.xserver.displayManager = {
      defaultSession = "default";
      session = [
        {
          manage = "desktop";
          name = "default";
          start = ''exec openbox-session'';
        }
      ];
}

This ugly fix works for both slick and tiny greeters and openbox session.

HumbabaTheTerribleCoder commented 1 year ago

Just wanted to confirm that @wheelie-turner's solution is working for me with lighdm's tiny greeter and using awesomewm - just to help with any searches out there.

My config file entry:

services.xserver.displayManager = {
      defaultSession = "default";
      session = [
        {
          manage = "desktop";
          name = "default";
          start = ''exec awesome'';
        }
      ];
      lightdm = {
        enable = true;
        greeters = {
          gtk.enable = false; #not sure if necessary, but it's true by default
          tiny.enable = true;
        };
      };
};
erplsf commented 11 months ago

Can confirm that this is also broken for none+herbstluftwm but works for none+awesome and none+xmonad on the latest release (23.x).

fdietze commented 10 months ago

Related for herbstluftwm: I think I broke none+herbstluftwm it with this fix: https://github.com/NixOS/nixpkgs/pull/237364

But I don't know what the correct solution should be to fix both use-cases.

Workaround:

      windowManager = {
        herbstluftwm.enable = true;
        session = [{
          name = "herbstluftwm";
          # workaround for https://github.com/NixOS/nixpkgs/pull/237364
          start = ''
            ${pkgs.herbstluftwm}/bin/herbstluftwm --locked 2>&1 > /tmp/herbstlog
          '';
        }];
      };