1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7 xcfg = config.services.xserver;
8 cfg = xcfg.desktopManager.plasma5;
9
10 inherit (pkgs) kdeApplications plasma5 libsForQt5 qt5 xorg;
11
12in
13
14{
15 options = {
16
17 services.xserver.desktopManager.plasma5 = {
18 enable = mkOption {
19 type = types.bool;
20 default = false;
21 description = "Enable the Plasma 5 (KDE 5) desktop environment.";
22 };
23
24 enableQt4Support = mkOption {
25 type = types.bool;
26 default = true;
27 description = ''
28 Enable support for Qt 4-based applications. Particularly, install the
29 Qt 4 version of the Breeze theme and a default backend for Phonon.
30 '';
31 };
32
33 };
34
35 };
36
37
38 config = mkMerge [
39 (mkIf (xcfg.enable && cfg.enable) {
40 services.xserver.desktopManager.session = singleton {
41 name = "plasma5";
42 bgSupport = true;
43 start = ''
44 # Load PulseAudio module for routing support.
45 # See http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/
46 ${optionalString config.hardware.pulseaudio.enable ''
47 ${getBin config.hardware.pulseaudio.package}/bin/pactl load-module module-device-manager "do_routing=1"
48 ''}
49
50 exec "${plasma5.startkde}"
51 '';
52 };
53
54 security.wrappers = {
55 kcheckpass.source = "${lib.getBin plasma5.plasma-workspace}/lib/libexec/kcheckpass";
56 "start_kdeinit".source = "${lib.getBin pkgs.kinit}/lib/libexec/kf5/start_kdeinit";
57 };
58
59 environment.systemPackages = with pkgs; with qt5; with libsForQt5; with plasma5; with kdeApplications;
60 [
61 frameworkintegration
62 kactivities
63 kauth
64 kcmutils
65 kconfig
66 kconfigwidgets
67 kcoreaddons
68 kdbusaddons
69 kdeclarative
70 kded
71 kdesu
72 kdnssd
73 kemoticons
74 kfilemetadata
75 kglobalaccel
76 kguiaddons
77 kiconthemes
78 kidletime
79 kimageformats
80 kinit
81 kio
82 kjobwidgets
83 knewstuff
84 knotifications
85 knotifyconfig
86 kpackage
87 kparts
88 kpeople
89 krunner
90 kservice
91 ktextwidgets
92 kwallet
93 kwallet-pam
94 kwalletmanager
95 kwayland
96 kwidgetsaddons
97 kxmlgui
98 kxmlrpcclient
99 plasma-framework
100 solid
101 sonnet
102 threadweaver
103
104 breeze-qt5
105 kactivitymanagerd
106 kde-cli-tools
107 kdecoration
108 kdeplasma-addons
109 kgamma5
110 khotkeys
111 kinfocenter
112 kmenuedit
113 kscreen
114 kscreenlocker
115 ksysguard
116 kwayland
117 kwin
118 kwrited
119 libkscreen
120 libksysguard
121 milou
122 plasma-integration
123 polkit-kde-agent
124 systemsettings
125
126 plasma-desktop
127 plasma-workspace
128 plasma-workspace-wallpapers
129
130 dolphin
131 dolphin-plugins
132 ffmpegthumbs
133 kdegraphics-thumbnailers
134 khelpcenter
135 kio-extras
136 konsole
137 oxygen
138 print-manager
139
140 breeze-icons
141 pkgs.hicolor_icon_theme
142
143 kde-gtk-config breeze-gtk
144
145 phonon-backend-gstreamer
146 ]
147
148 ++ lib.optionals cfg.enableQt4Support [ breeze-qt4 pkgs.phonon-backend-gstreamer ]
149
150 # Optional hardware support features
151 ++ lib.optional config.hardware.bluetooth.enable bluedevil
152 ++ lib.optional config.networking.networkmanager.enable plasma-nm
153 ++ lib.optional config.hardware.pulseaudio.enable plasma-pa
154 ++ lib.optional config.powerManagement.enable powerdevil
155 ++ lib.optional config.services.colord.enable colord-kde
156 ++ lib.optionals config.services.samba.enable [ kdenetwork-filesharing pkgs.samba ];
157
158 environment.pathsToLink = [ "/share" ];
159
160 environment.etc = singleton {
161 source = xcfg.xkbDir;
162 target = "X11/xkb";
163 };
164
165 environment.variables = {
166 # Enable GTK applications to load SVG icons
167 GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache";
168 };
169
170 fonts.fonts = with pkgs; [ noto-fonts hack-font ];
171 fonts.fontconfig.defaultFonts = {
172 monospace = [ "Hack" "Noto Mono" ];
173 sansSerif = [ "Noto Sans" ];
174 serif = [ "Noto Serif" ];
175 };
176
177 programs.ssh.askPassword = "${plasma5.ksshaskpass.out}/bin/ksshaskpass";
178
179 # Enable helpful DBus services.
180 services.udisks2.enable = true;
181 services.upower.enable = config.powerManagement.enable;
182 services.dbus.packages =
183 mkIf config.services.printing.enable [ pkgs.system-config-printer ];
184
185 # Extra UDEV rules used by Solid
186 services.udev.packages = [
187 pkgs.libmtp
188 pkgs.media-player-info
189 ];
190
191 services.xserver.displayManager.sddm = {
192 theme = "breeze";
193 };
194
195 security.pam.services.kde = { allowNullPassword = true; };
196
197 # Doing these one by one seems silly, but we currently lack a better
198 # construct for handling common pam configs.
199 security.pam.services.gdm.enableKwallet = true;
200 security.pam.services.kdm.enableKwallet = true;
201 security.pam.services.lightdm.enableKwallet = true;
202 security.pam.services.sddm.enableKwallet = true;
203 security.pam.services.slim.enableKwallet = true;
204
205 })
206 ];
207
208}