1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 xcfg = config.services.xserver;
8 cfg = xcfg.desktopManager.xfce;
9
10in
11
12{
13 options = {
14
15 services.xserver.desktopManager.xfce = {
16 enable = mkOption {
17 type = types.bool;
18 default = false;
19 description = "Enable the Xfce desktop environment.";
20 };
21
22 thunarPlugins = mkOption {
23 default = [];
24 type = types.listOf types.package;
25 example = literalExample "[ pkgs.xfce.thunar-archive-plugin ]";
26 description = ''
27 A list of plugin that should be installed with Thunar.
28 '';
29 };
30
31 noDesktop = mkOption {
32 type = types.bool;
33 default = false;
34 description = "Don't install XFCE desktop components (xfdesktop, panel and notification daemon).";
35 };
36
37 extraSessionCommands = mkOption {
38 default = "";
39 type = types.lines;
40 description = ''
41 Shell commands executed just before XFCE is started.
42 '';
43 };
44
45 enableXfwm = mkOption {
46 type = types.bool;
47 default = true;
48 description = "Enable the XFWM (default) window manager.";
49 };
50
51 screenLock = mkOption {
52 type = types.enum [ "xscreensaver" "xlockmore" "slock" ];
53 default = "xlockmore";
54 description = "Application used by XFCE to lock the screen.";
55 };
56 };
57
58 };
59
60
61 config = mkIf (xcfg.enable && cfg.enable) {
62
63 services.xserver.desktopManager.session = singleton
64 { name = "xfce";
65 bgSupport = true;
66 start =
67 ''
68 ${cfg.extraSessionCommands}
69
70 # Set GTK_PATH so that GTK+ can find the theme engines.
71 export GTK_PATH="${config.system.path}/lib/gtk-2.0:${config.system.path}/lib/gtk-3.0"
72
73 # Set GTK_DATA_PREFIX so that GTK+ can find the Xfce themes.
74 export GTK_DATA_PREFIX=${config.system.path}
75
76 ${pkgs.stdenv.shell} ${pkgs.xfce.xinitrc} &
77 waitPID=$!
78 '';
79 };
80
81 services.xserver.updateDbusEnvironment = true;
82
83 environment.systemPackages =
84 [ pkgs.gtk2.out # To get GTK+'s themes and gtk-update-icon-cache
85 pkgs.hicolor_icon_theme
86 pkgs.tango-icon-theme
87 pkgs.shared_mime_info
88 pkgs.which # Needed by the xfce's xinitrc script.
89 pkgs."${cfg.screenLock}"
90 pkgs.xfce.exo
91 pkgs.xfce.gtk_xfce_engine
92 pkgs.xfce.mousepad
93 pkgs.xfce.ristretto
94 pkgs.xfce.terminal
95 (pkgs.xfce.thunar.override { thunarPlugins = cfg.thunarPlugins; })
96 pkgs.xfce.xfce4icontheme
97 pkgs.xfce.xfce4session
98 pkgs.xfce.xfce4settings
99 pkgs.xfce.xfce4mixer
100 pkgs.xfce.xfce4volumed
101 pkgs.xfce.xfce4-screenshooter
102 pkgs.xfce.xfconf
103 # This supplies some "abstract" icons such as
104 # "utilities-terminal" and "accessories-text-editor".
105 pkgs.gnome3.defaultIconTheme
106 pkgs.desktop_file_utils
107 pkgs.xfce.libxfce4ui
108 pkgs.xfce.garcon
109 pkgs.xfce.thunar_volman
110 pkgs.xfce.gvfs
111 pkgs.xfce.xfce4_appfinder
112 pkgs.xfce.tumbler # found via dbus
113 ]
114 ++ optional cfg.enableXfwm pkgs.xfce.xfwm4
115 ++ optional config.powerManagement.enable pkgs.xfce.xfce4_power_manager
116 ++ optional config.networking.networkmanager.enable pkgs.networkmanagerapplet
117 ++ optionals (!cfg.noDesktop)
118 [ pkgs.xfce.xfce4panel
119 pkgs.xfce.xfdesktop
120 pkgs.xfce.xfce4notifyd # found via dbus
121 ];
122
123 environment.pathsToLink =
124 [ "/share/xfce4" "/share/themes" "/share/mime" "/share/desktop-directories" "/share/gtksourceview-2.0" ];
125
126 environment.variables.GIO_EXTRA_MODULES = [ "${pkgs.xfce.gvfs}/lib/gio/modules" ];
127
128 # Enable helpful DBus services.
129 services.udisks2.enable = true;
130 services.upower.enable = config.powerManagement.enable;
131
132 };
133
134}