4

I'm using NixOS with XMonad as a window manager, which was enabled via the configurations.nix. This works fine.

After booting, the initial login is done via the NixOS login gui.

On a Debian system for instance systemd can be configured to boot only to the terminal and not directly to a desktop environment. One can setup an .xinit file then to start the chosen window manager or desktop environment without using any display manager (like lightdm, kdm...). It's started then by calling startx.

  1. How would described effect be done in Nix? I guess there's an declarative way to do so.
  2. Another question, partly related to this, is: After changing xserver settings in the configurations.nix (e.g. in services.xserver.synaptics) and rebuilding via nixos-rebuild switch/test, what do I have to do in order to take them in effect?
1
  • 1
    Voting to migrate this to Super User. You'll probably be better off there. :)
    – Siguza
    Jul 17, 2016 at 11:16

3 Answers 3

1

Those are 2 separate questions, thus I believe you'd be much better splitting them into 2 StackOverflow questions (it's much harder now to answer e.g. only one of them). That said:

  1. AFAIK, people building the NixOS are not aware of a way to do this in systemd. If you know of such method, I believe there might be interested to learn about it!

  2. I suppose you want:

    $ systemctl start display-manager.service   # CAUTION: see NOTE below!!!
    

    NOTE: this will kill any open X session! (I guess that this might be the reason why it's not done automatically on nixos-rebuild switch...)

    By the way, you may have noticed that after nixos-rebuild switch, a message is shown, something like: "display-manager.service is not restarted". That's what led me to find the answer to this question when I needed it myself.

1
  • systemctl start display-manager.service → The point of the question is to get the display manager out of the way. That’s what startx is for: a way to launch X on the current console, using the current login session.
    – phg
    Feb 9, 2017 at 11:34
0

One way to do it is to enable startx, which will be treated as a display manager:

services.xserver.displayManager.startx.enable = true;

Another way to accomplish this is to bypass the display manager by logging in automatically from the TTY login prompt. NixOS default display manager being lightdm, you do that by adding the following lines to your configuration:

lightdm = {
  enable = true;
  autoLogin.enable = true;
  autoLogin.user = "username";
};
0

You can prevent NixOS from automatically starting the X server (and consequently launching into the GUI) by setting the following in your configuration.nix:

services.xserver.autorun = false;

The change will take effect immediately upon running nixos-rebuild switch.

To start the X server manually, run as root:

systemctl start display-manager.service

To exit the GUI, open a console and stop the display manager service:

systemctl stop display-manager.service

Source: NixOS manual

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.