1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 xcfg = config.services.xserver; 8 cfg = xcfg.desktopManager.kde5; 9 xorg = pkgs.xorg; 10 11 kde5 = pkgs.kde5; 12 13in 14 15{ 16 options = { 17 18 services.xserver.desktopManager.kde5 = { 19 enable = mkOption { 20 type = types.bool; 21 default = false; 22 description = "Enable the Plasma 5 (KDE 5) desktop environment."; 23 }; 24 25 }; 26 27 }; 28 29 30 config = mkIf (xcfg.enable && cfg.enable) { 31 32 warnings = optional config.services.xserver.desktopManager.kde4.enable 33 "KDE 4 should not be enabled at the same time as KDE 5"; 34 35 services.xserver.desktopManager.session = singleton { 36 name = "kde5"; 37 bgSupport = true; 38 start = '' 39 # Load PulseAudio module for routing support. 40 # See http://colin.guthr.ie/2009/10/so-how-does-the-kde-pulseaudio-support-work-anyway/ 41 ${optionalString config.hardware.pulseaudio.enable '' 42 ${getBin config.hardware.pulseaudio.package}/bin/pactl load-module module-device-manager "do_routing=1" 43 ''} 44 45 exec "${kde5.startkde}" 46 47 ''; 48 }; 49 50 security.setuidOwners = [ 51 { 52 program = "kcheckpass"; 53 source = "${kde5.plasma-workspace.out}/lib/libexec/kcheckpass"; 54 owner = "root"; 55 setuid = true; 56 } 57 { 58 program = "start_kdeinit"; 59 source = "${kde5.kinit.out}/lib/libexec/kf5/start_kdeinit"; 60 owner = "root"; 61 setuid = true; 62 } 63 ]; 64 65 environment.systemPackages = 66 [ 67 kde5.frameworkintegration 68 kde5.kactivities 69 kde5.kauth 70 kde5.kcmutils 71 kde5.kconfig 72 kde5.kconfigwidgets 73 kde5.kcoreaddons 74 kde5.kdbusaddons 75 kde5.kdeclarative 76 kde5.kded 77 kde5.kdesu 78 kde5.kdnssd 79 kde5.kemoticons 80 kde5.kfilemetadata 81 kde5.kglobalaccel 82 kde5.kguiaddons 83 kde5.kiconthemes 84 kde5.kidletime 85 kde5.kimageformats 86 kde5.kinit 87 kde5.kio 88 kde5.kjobwidgets 89 kde5.knewstuff 90 kde5.knotifications 91 kde5.knotifyconfig 92 kde5.kpackage 93 kde5.kparts 94 kde5.kpeople 95 kde5.krunner 96 kde5.kservice 97 kde5.ktextwidgets 98 kde5.kwallet 99 kde5.kwayland 100 kde5.kwidgetsaddons 101 kde5.kxmlgui 102 kde5.kxmlrpcclient 103 kde5.plasma-framework 104 kde5.solid 105 kde5.sonnet 106 kde5.threadweaver 107 108 kde5.breeze 109 kde5.kactivitymanagerd 110 kde5.kde-cli-tools 111 kde5.kdecoration 112 kde5.kdeplasma-addons 113 kde5.kgamma5 114 kde5.khelpcenter 115 kde5.khotkeys 116 kde5.kinfocenter 117 kde5.kmenuedit 118 kde5.kscreen 119 kde5.kscreenlocker 120 kde5.ksysguard 121 kde5.kwayland 122 kde5.kwin 123 kde5.kwrited 124 kde5.libkscreen 125 kde5.libksysguard 126 kde5.milou 127 kde5.oxygen 128 kde5.plasma-integration 129 kde5.polkit-kde-agent 130 kde5.systemsettings 131 132 kde5.plasma-desktop 133 kde5.plasma-workspace 134 kde5.plasma-workspace-wallpapers 135 136 kde5.dolphin 137 kde5.dolphin-plugins 138 kde5.ffmpegthumbs 139 kde5.kdegraphics-thumbnailers 140 kde5.kio-extras 141 kde5.konsole 142 kde5.print-manager 143 144 # Oxygen icons moved to KDE Frameworks 5.16 and later. 145 (kde5.oxygen-icons or kde5.oxygen-icons5) 146 pkgs.hicolor_icon_theme 147 148 kde5.kde-gtk-config 149 150 pkgs.phonon-backend-gstreamer 151 pkgs.qt5.phonon-backend-gstreamer 152 ] 153 154 # Plasma 5.5 and later has a Breeze GTK theme. 155 # If it is not available, Orion is very similar to Breeze. 156 ++ lib.optional (!(lib.hasAttr "breeze-gtk" kde5)) pkgs.orion 157 158 # Install Breeze icons if available 159 ++ lib.optional (lib.hasAttr "breeze-icons" kde5) kde5.breeze-icons 160 161 # Install activity manager if available 162 ++ lib.optional (lib.hasAttr "kactivitymanagerd" kde5) kde5.kactivitymanagerd 163 164 # frameworkintegration was split with plasma-integration in Plasma 5.6 165 ++ lib.optional (lib.hasAttr "plasma-integration" kde5) kde5.plasma-integration 166 167 # Optional hardware support features 168 ++ lib.optional config.hardware.bluetooth.enable kde5.bluedevil 169 ++ lib.optional config.networking.networkmanager.enable kde5.plasma-nm 170 ++ lib.optional config.hardware.pulseaudio.enable kde5.plasma-pa 171 ++ lib.optional config.powerManagement.enable kde5.powerdevil 172 ++ lib.optional config.services.colord.enable pkgs.colord-kde 173 ++ lib.optionals config.services.samba.enable [ kde5.kdenetwork-filesharing pkgs.samba ]; 174 175 environment.pathsToLink = [ "/share" ]; 176 177 environment.etc = singleton { 178 source = "${pkgs.xkeyboard_config}/etc/X11/xkb"; 179 target = "X11/xkb"; 180 }; 181 182 # Enable GTK applications to load SVG icons 183 environment.variables = 184 { 185 GST_PLUGIN_SYSTEM_PATH_1_0 = 186 lib.makeSearchPath "/lib/gstreamer-1.0" 187 (builtins.map (pkg: pkg.out) (with pkgs.gst_all_1; [ 188 gstreamer 189 gst-plugins-base 190 gst-plugins-good 191 gst-plugins-ugly 192 gst-plugins-bad 193 gst-libav # for mp3 playback 194 ])); 195 } 196 // (if (lib.hasAttr "breeze-icons" kde5) 197 then { GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"; } 198 else { }); 199 200 fonts.fonts = [ (kde5.oxygen-fonts or pkgs.noto-fonts) ]; 201 202 programs.ssh.askPassword = "${kde5.ksshaskpass.out}/bin/ksshaskpass"; 203 204 # Enable helpful DBus services. 205 services.udisks2.enable = true; 206 services.upower.enable = config.powerManagement.enable; 207 208 # Extra UDEV rules used by Solid 209 services.udev.packages = [ 210 pkgs.libmtp 211 pkgs.media-player-info 212 ]; 213 214 services.xserver.displayManager.sddm = { 215 theme = "breeze"; 216 themes = [ 217 kde5.ecm # for the setup-hook 218 kde5.plasma-workspace 219 kde5.breeze-icons 220 (kde5.oxygen-icons or kde5.oxygen-icons5) 221 ]; 222 }; 223 224 security.pam.services.kde = { allowNullPassword = true; }; 225 226 }; 227 228}