1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6 cfg = config.services.xserver.desktopManager.xfce;
7in
8
9{
10 options = {
11 services.xserver.desktopManager.xfce = {
12 enable = mkOption {
13 type = types.bool;
14 default = false;
15 description = "Enable the Xfce desktop environment.";
16 };
17
18 thunarPlugins = mkOption {
19 default = [];
20 type = types.listOf types.package;
21 example = literalExample "[ pkgs.xfce.thunar-archive-plugin ]";
22 description = ''
23 A list of plugin that should be installed with Thunar.
24 '';
25 };
26
27 noDesktop = mkOption {
28 type = types.bool;
29 default = false;
30 description = "Don't install XFCE desktop components (xfdesktop, panel and notification daemon).";
31 };
32
33 extraSessionCommands = mkOption {
34 default = "";
35 type = types.lines;
36 description = ''
37 Shell commands executed just before XFCE is started.
38 '';
39 };
40
41 enableXfwm = mkOption {
42 type = types.bool;
43 default = true;
44 description = "Enable the XFWM (default) window manager.";
45 };
46 };
47 };
48
49 config = mkIf cfg.enable {
50 environment.systemPackages = with pkgs.xfce // pkgs; [
51 # Get GTK+ themes and gtk-update-icon-cache
52 gtk2.out
53
54 # Supplies some abstract icons such as:
55 # utilities-terminal, accessories-text-editor
56 gnome3.defaultIconTheme
57
58 hicolor-icon-theme
59 tango-icon-theme
60 xfce4-icon-theme
61
62 # Needed by Xfce's xinitrc script
63 # TODO: replace with command -v
64 which
65
66 exo
67 garcon
68 gtk-xfce-engine
69 gvfs
70 libxfce4ui
71 tumbler
72 xfconf
73
74 mousepad
75 ristretto
76 xfce4-appfinder
77 xfce4-screenshooter
78 xfce4-session
79 xfce4-settings
80 xfce4-terminal
81
82 (thunar.override { thunarPlugins = cfg.thunarPlugins; })
83 thunar-volman # TODO: drop
84 ] ++ (if config.hardware.pulseaudio.enable
85 then [ xfce4-mixer-pulse xfce4-volumed-pulse ]
86 else [ xfce4-mixer xfce4-volumed ])
87 # TODO: NetworkManager doesn't belong here
88 ++ optionals config.networking.networkmanager.enable [ networkmanagerapplet ]
89 ++ optionals config.powerManagement.enable [ xfce4-power-manager ]
90 ++ optionals cfg.enableXfwm [ xfwm4 ]
91 ++ optionals (!cfg.noDesktop) [
92 xfce4-panel
93 xfce4-notifyd
94 xfdesktop
95 ];
96
97 environment.pathsToLink = [
98 "/share/xfce4"
99 "/share/themes"
100 "/share/gtksourceview-2.0"
101 ];
102
103 environment.variables = {
104 GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
105 GIO_EXTRA_MODULES = [ "${pkgs.xfce.gvfs}/lib/gio/modules" ];
106 };
107
108 services.xserver.desktopManager.session = [{
109 name = "xfce";
110 bgSupport = true;
111 start = ''
112 ${cfg.extraSessionCommands}
113
114 # Set GTK_PATH so that GTK+ can find the theme engines.
115 export GTK_PATH="${config.system.path}/lib/gtk-2.0:${config.system.path}/lib/gtk-3.0"
116
117 # Set GTK_DATA_PREFIX so that GTK+ can find the Xfce themes.
118 export GTK_DATA_PREFIX=${config.system.path}
119
120 ${pkgs.runtimeShell} ${pkgs.xfce.xinitrc} &
121 waitPID=$!
122 '';
123 }];
124
125 services.xserver.updateDbusEnvironment = true;
126
127 # Enable helpful DBus services.
128 services.udisks2.enable = true;
129 services.upower.enable = config.powerManagement.enable;
130 };
131}