nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
7.03k stars 1.81k forks source link

Add more documentation about xsession #76

Closed pmiddend closed 7 years ago

pmiddend commented 7 years ago

I want to use home manager for X related stuff and I'm not sure how, despite the note in the README about disabling the NixOS-wide window manager properties. I added the following to my home.nix file:

  xsession.enable = true;
  xsession.windowManager = "${pkgs.i3}/bin/i3";

And in my configuration.nix, I just enabled the X server. On boot, I was then greeted by my desktop manager, which only had "xterm" as session type to offer. Shouldn't there be "xsession" or something? I had a valid ~/.xsession present, so that much worked

rycee commented 7 years ago

I'm not sure I understand. Did X not start up OK when you had xsession.enable and xsession.windowManager set?

Basically the way it is intended to function is to ignore the session type and instead use ~/.xsession to start the X session. So, Home Manager creates this file and NixOS will look for this file when it starts X up. If it exists then NixOS will use ~/.xsession instead of using the session type from the desktop manager. In other words having "xterm" as session type shouldn't matter, it should always use your xsession file.

But I think you are right, it would be nice to have "xsession" as a possible session type instead so that a NixOS user could choose whether to use the ~/.xsession file or some other session. But this would have to be done in Nixpkgs, Home Manager cannot do much.

Another thing that possibly would be nice to have is a "home-manager" session type in NixOS but I think that will have to wait until we have found a nice way to integrate Home Manager into NixOS (probably through NixUP).

pmiddend commented 7 years ago

Well, X started, but it didn't start my window manager. I just got a mouse cursor and a wallpaper, which is weird. You're saying that choosing the xterm profile is fine, though?

rycee commented 7 years ago

Yeah, it should start up your window manager regardless. Can you paste your Home Manager xsession config? In particular the xsession.windowManager option? Also your ~/.xsession file, in particular the line above systemctl --user stop graphical-session.target (the line that should correspond to your xsession.windowManager option).

In my case I have

xsession.windowManager =
      let
        xmonad = pkgs.xmonad-with-packages.override {
          packages = self: [ self.xmonad-contrib self.taffybar ];
        };
      in
        "${xmonad}/bin/xmonad";

in my Home Manager configuration and this shows up as /nix/store/n0lxrs7clsdcmmr9pr9fj8h3dsy4wgjf-xmonad-with-packages/bin/xmonad in my ~/.xsession file.

pmiddend commented 7 years ago

I figured out what was wrong. The problem was, I had to add i3 and i3status to my home.packages list. journalctl told me that on startup, i3 (which was found) couldn't find xdotool, i3status and i3bar, which is curious, because at least i3bar is part of the i3 package. I think if you set up i3 as a window manager via the global configuration.nix, some additional magic happens, which does not happen when I set it up with home-manager.

uvNikita commented 7 years ago

i3 module from nixpkgs indeed installs some additional packages: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/x11/window-managers/i3.nix#L42. We are currently working on full support of i3 in home-manager too: https://github.com/rycee/home-manager/pull/79. The goal is to have more configurable module than the one in nixpkgs while supporting sensible default behavior. Meaning that it should be enough just to add something like xsession.windowManager.i3.enable = true in the configuration file and get minimal working i3 for the given user.