Home-manager: cannot enable services

Created on 22 Mar 2017  Â·  6Comments  Â·  Source: nix-community/home-manager

<service>.enable = true; does not seem to work for me. I tried

  • xscreensaver
  • network-manager-applet
  • dunst and
  • udiskie.

For xscreensaver I tried changing WantedBy = [ "graphical-session.target" ]; to "graphical.target", but that's about my only idea as I am not the greatest systemd fan or expert.

Most helpful comment

@alibabzo If you let home-manager do the xsession you should pretty much only need services.xserver.enable = true; in your global configuration.

For example, my system wide configuration.nix contains

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

and my home-manager configuration has

  xsession = {
    enable = true;
    windowManager =
      let
        xmonad = pkgs.xmonad-with-packages.override {
          packages = self: [ self.xmonad-contrib self.taffybar ];
        };
      in
        "${xmonad}/bin/xmonad";
    initExtra = ''
      # Set a default pointer.
      xsetroot -cursor_name left_ptr

      # Turn off beeps.
      xset -b

      # Quicker blanking of screen.
      xset dpms 120 360 800
    '';
  };

(For xmonad I also have a line home.file.".xmonad/xmonad.hs".source = dotfiles/xmonad.hs; to manage my xmonad configuration next to the home-manager files.)

All 6 comments

Unfortunately, as-is the graphical services will only work out of the box if you also use home-manager to manage your xsession files, i.e., have . You can see the magic incantations in the xsessions module. From my configuration:

{
  # …

  xsession = {
    enable = true;
    windowManager =
      let
        xmonad = pkgs.xmonad-with-packages.override {
          packages = self: [ self.xmonad-contrib self.taffybar ];
        };
      in
        "${xmonad}/bin/xmonad";
    initExtra = ''
      # Set a default pointer.
      xsetroot -cursor_name left_ptr

      # Turn off beeps.
      xset -b

      # Quicker blanking of screen.
      xset dpms 120 360 800
    '';
  };

  # …
}

If you don't want to use home-manager for your xsession I think you can try copy pasting the systemd commands from the xsession module into your own xsession file.

The systemd from 17.03 already contains the graphical-session.target so if you have switched to 17.03 then I don't think you don't need to add it.

Hi @rycee,
I don't want to derail this thread but I was wondering - if you configure xsession in home-manager, what do you put in xserver global configuration to enable it? If I keep windowManager.xmonad.enable = true, it seems to run the xmonad from my global configuration and not my local one.

@alibabzo If you let home-manager do the xsession you should pretty much only need services.xserver.enable = true; in your global configuration.

For example, my system wide configuration.nix contains

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

and my home-manager configuration has

  xsession = {
    enable = true;
    windowManager =
      let
        xmonad = pkgs.xmonad-with-packages.override {
          packages = self: [ self.xmonad-contrib self.taffybar ];
        };
      in
        "${xmonad}/bin/xmonad";
    initExtra = ''
      # Set a default pointer.
      xsetroot -cursor_name left_ptr

      # Turn off beeps.
      xset -b

      # Quicker blanking of screen.
      xset dpms 120 360 800
    '';
  };

(For xmonad I also have a line home.file.".xmonad/xmonad.hs".source = dotfiles/xmonad.hs; to manage my xmonad configuration next to the home-manager files.)

Thanks for the clarification! I'm happy with this solution.

@rycee I believe layout = "us"; is misleading in your example. As soon as home-manager does the xsession you will need (correct me if I am wrong) to use home.keyboard.layout to set the keyboard layout for the xsession.

Well the changlog for 19.09 seems to indicate that it is going to change ... which is for the best I would say. If I understand it correctly from 19.09 the system setting for the keyboard layout will be preserved. Is that correct ?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Dav1d23 picture Dav1d23  Â·  5Comments

mightybyte picture mightybyte  Â·  5Comments

throwup picture throwup  Â·  6Comments

PierreR picture PierreR  Â·  5Comments

wpcarro picture wpcarro  Â·  3Comments