at 18.09-beta 6.8 kB view raw
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; 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 a 29 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 if [ -f "$HOME/.config/kdeglobals" ] 51 then 52 # Remove extraneous font style names. 53 # See also: https://phabricator.kde.org/D9070 54 ${getBin pkgs.gnused}/bin/sed -i "$HOME/.config/kdeglobals" \ 55 -e '/^fixed=/ s/,Regular$//' \ 56 -e '/^font=/ s/,Regular$//' \ 57 -e '/^menuFont=/ s/,Regular$//' \ 58 -e '/^smallestReadableFont=/ s/,Regular$//' \ 59 -e '/^toolBarFont=/ s/,Regular$//' 60 fi 61 62 exec "${getBin plasma5.plasma-workspace}/bin/startkde" 63 ''; 64 }; 65 66 security.wrappers = { 67 kcheckpass.source = "${lib.getBin plasma5.plasma-workspace}/lib/libexec/kcheckpass"; 68 "start_kdeinit".source = "${lib.getBin pkgs.kinit}/lib/libexec/kf5/start_kdeinit"; 69 kwin_wayland = { 70 source = "${lib.getBin plasma5.kwin}/bin/kwin_wayland"; 71 capabilities = "cap_sys_nice+ep"; 72 }; 73 }; 74 75 environment.systemPackages = with pkgs; with qt5; with libsForQt5; with plasma5; with kdeApplications; 76 [ 77 frameworkintegration 78 kactivities 79 kauth 80 kcmutils 81 kconfig 82 kconfigwidgets 83 kcoreaddons 84 kdbusaddons 85 kdeclarative 86 kded 87 kdesu 88 kdnssd 89 kemoticons 90 kfilemetadata 91 kglobalaccel 92 kguiaddons 93 kiconthemes 94 kidletime 95 kimageformats 96 kinit 97 kio 98 kjobwidgets 99 knewstuff 100 knotifications 101 knotifyconfig 102 kpackage 103 kparts 104 kpeople 105 krunner 106 kservice 107 ktextwidgets 108 kwallet 109 kwallet-pam 110 kwalletmanager 111 kwayland 112 kwidgetsaddons 113 kxmlgui 114 kxmlrpcclient 115 plasma-framework 116 solid 117 sonnet 118 threadweaver 119 120 breeze-qt5 121 kactivitymanagerd 122 kde-cli-tools 123 kdecoration 124 kdeplasma-addons 125 kgamma5 126 khotkeys 127 kinfocenter 128 kmenuedit 129 kscreen 130 kscreenlocker 131 ksysguard 132 kwayland 133 kwin 134 kwrited 135 libkscreen 136 libksysguard 137 milou 138 plasma-integration 139 polkit-kde-agent 140 systemsettings 141 142 plasma-desktop 143 plasma-workspace 144 plasma-workspace-wallpapers 145 146 dolphin 147 dolphin-plugins 148 ffmpegthumbs 149 kdegraphics-thumbnailers 150 khelpcenter 151 kio-extras 152 konsole 153 oxygen 154 print-manager 155 156 breeze-icons 157 pkgs.hicolor-icon-theme 158 159 kde-gtk-config breeze-gtk 160 161 qtvirtualkeyboard 162 163 libsForQt56.phonon-backend-gstreamer 164 libsForQt5.phonon-backend-gstreamer 165 ] 166 167 ++ lib.optionals cfg.enableQt4Support [ pkgs.phonon-backend-gstreamer ] 168 169 # Optional hardware support features 170 ++ lib.optional config.hardware.bluetooth.enable bluedevil 171 ++ lib.optional config.networking.networkmanager.enable plasma-nm 172 ++ lib.optional config.hardware.pulseaudio.enable plasma-pa 173 ++ lib.optional config.powerManagement.enable powerdevil 174 ++ lib.optional config.services.colord.enable colord-kde 175 ++ lib.optionals config.services.samba.enable [ kdenetwork-filesharing pkgs.samba ]; 176 177 environment.pathsToLink = [ 178 # FIXME: modules should link subdirs of `/share` rather than relying on this 179 "/share" 180 ]; 181 182 environment.etc = singleton { 183 source = xcfg.xkbDir; 184 target = "X11/xkb"; 185 }; 186 187 environment.variables = { 188 # Enable GTK applications to load SVG icons 189 GDK_PIXBUF_MODULE_FILE = "${pkgs.librsvg.out}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"; 190 }; 191 192 fonts.fonts = with pkgs; [ noto-fonts hack-font ]; 193 fonts.fontconfig.defaultFonts = { 194 monospace = [ "Hack" "Noto Mono" ]; 195 sansSerif = [ "Noto Sans" ]; 196 serif = [ "Noto Serif" ]; 197 }; 198 199 programs.ssh.askPassword = mkDefault "${plasma5.ksshaskpass.out}/bin/ksshaskpass"; 200 201 # Enable helpful DBus services. 202 services.udisks2.enable = true; 203 services.upower.enable = config.powerManagement.enable; 204 services.dbus.packages = 205 mkIf config.services.printing.enable [ pkgs.system-config-printer ]; 206 207 # Extra UDEV rules used by Solid 208 services.udev.packages = [ 209 pkgs.libmtp 210 pkgs.media-player-info 211 ]; 212 213 services.xserver.displayManager.sddm = { 214 theme = mkDefault "breeze"; 215 }; 216 217 security.pam.services.kde = { allowNullPassword = true; }; 218 219 # Doing these one by one seems silly, but we currently lack a better 220 # construct for handling common pam configs. 221 security.pam.services.gdm.enableKwallet = true; 222 security.pam.services.kdm.enableKwallet = true; 223 security.pam.services.lightdm.enableKwallet = true; 224 security.pam.services.sddm.enableKwallet = true; 225 security.pam.services.slim.enableKwallet = true; 226 227 # Update the start menu for each user that has `isNormalUser` set. 228 system.activationScripts.plasmaSetup = stringAfter [ "users" "groups" ] 229 (concatStringsSep "\n" 230 (mapAttrsToList (name: value: "${pkgs.su}/bin/su ${name} -c ${pkgs.libsForQt5.kservice}/bin/kbuildsycoca5") 231 (filterAttrs (n: v: v.isNormalUser) config.users.users))); 232 }) 233 ]; 234 235}