summary refs log tree commit diff
path: root/nixos/modules/services/x11/desktop-managers/xfce.nix
blob: 6965c6d26467a22329df9e61540640ddcbfe81a5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
{ config, lib, pkgs, ... }:

with lib;

let
  cfg = config.services.xserver.desktopManager.xfce;
in

{
  options = {
    services.xserver.desktopManager.xfce = {
      enable = mkOption {
        type = types.bool;
        default = false;
        description = "Enable the Xfce desktop environment.";
      };

      thunarPlugins = mkOption {
        default = [];
        type = types.listOf types.package;
        example = literalExample "[ pkgs.xfce.thunar-archive-plugin ]";
        description = ''
          A list of plugin that should be installed with Thunar.
        '';
      };

      noDesktop = mkOption {
        type = types.bool;
        default = false;
        description = "Don't install XFCE desktop components (xfdesktop, panel and notification daemon).";
      };

      extraSessionCommands = mkOption {
        default = "";
        type = types.lines;
        description = ''
          Shell commands executed just before XFCE is started.
        '';
      };

      enableXfwm = mkOption {
        type = types.bool;
        default = true;
        description = "Enable the XFWM (default) window manager.";
      };
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = with pkgs.xfce // pkgs; [
      # Get GTK themes and gtk-update-icon-cache
      gtk2.out

      # Supplies some abstract icons such as:
      # utilities-terminal, accessories-text-editor
      gnome3.adwaita-icon-theme

      hicolor-icon-theme
      tango-icon-theme
      xfce4-icon-theme

      # Needed by Xfce's xinitrc script
      # TODO: replace with command -v
      which

      exo
      garcon
      gtk-xfce-engine
      libxfce4ui
      tumbler
      xfconf

      mousepad
      ristretto
      xfce4-appfinder
      xfce4-screenshooter
      xfce4-session
      xfce4-settings
      xfce4-terminal

      (thunar.override { thunarPlugins = cfg.thunarPlugins; })
      thunar-volman # TODO: drop
    ] ++ (if config.hardware.pulseaudio.enable
          then [ xfce4-mixer-pulse xfce4-volumed-pulse ]
          else [ xfce4-mixer xfce4-volumed ])
      # TODO: NetworkManager doesn't belong here
      ++ optionals config.networking.networkmanager.enable [ networkmanagerapplet ]
      ++ optionals config.powerManagement.enable [ xfce4-power-manager ]
      ++ optionals cfg.enableXfwm [ xfwm4 ]
      ++ optionals (!cfg.noDesktop) [
        xfce4-panel
        xfce4-notifyd
        xfdesktop
      ];

    environment.pathsToLink = [
      "/share/xfce4"
      "/share/themes"
      "/share/gtksourceview-2.0"
    ];

    services.xserver.gdk-pixbuf.modulePackages = [ pkgs.librsvg ];

    services.xserver.desktopManager.session = [{
      name = "xfce";
      bgSupport = true;
      start = ''
        ${cfg.extraSessionCommands}

        ${pkgs.runtimeShell} ${pkgs.xfce.xinitrc} &
        waitPID=$!
      '';
    }];

    services.xserver.updateDbusEnvironment = true;

    # Enable helpful DBus services.
    services.udisks2.enable = true;
    services.upower.enable = config.powerManagement.enable;
    services.gvfs.enable = true;
    services.gvfs.package = pkgs.xfce.gvfs;
  };
}