8 cfg = config.services.desktopManager.plasma6;
10 inherit (pkgs) kdePackages;
11 inherit (lib) literalExpression mkDefault mkIf mkOption mkPackageOption types;
14 # will be rebuilt automatically
15 rm -fv "$HOME/.cache/ksycoca"*
19 services.desktopManager.plasma6 = {
23 description = "Enable the Plasma 6 (KDE 6) desktop environment.";
26 enableQt5Integration = mkOption {
29 description = "Enable Qt 5 integration (theming, etc). Disable for a pure Qt 6 system.";
32 notoPackage = mkPackageOption pkgs "Noto fonts - used for UI by default" {
33 default = ["noto-fonts"];
34 example = "noto-fonts-lgc-plus";
38 environment.plasma6.excludePackages = mkOption {
39 description = "List of default packages to exclude from the configuration";
40 type = types.listOf types.package;
42 example = literalExpression "[ pkgs.kdePackages.elisa ]";
47 (lib.mkRenamedOptionModule [ "services" "xserver" "desktopManager" "plasma6" "enable" ] [ "services" "desktopManager" "plasma6" "enable" ])
48 (lib.mkRenamedOptionModule [ "services" "xserver" "desktopManager" "plasma6" "enableQt5Integration" ] [ "services" "desktopManager" "plasma6" "enableQt5Integration" ])
49 (lib.mkRenamedOptionModule [ "services" "xserver" "desktopManager" "plasma6" "notoPackage" ] [ "services" "desktopManager" "plasma6" "notoPackage" ])
52 config = mkIf cfg.enable {
55 assertion = cfg.enable -> !config.services.xserver.desktopManager.plasma5.enable;
56 message = "Cannot enable plasma5 and plasma6 at the same time!";
61 programs.xwayland.enable = true;
62 environment.systemPackages = with kdePackages; let
64 qtwayland # Hack? To make everything run on Wayland
65 qtsvg # Needed to render SVG icons
67 # Frameworks with globally loadable bits
68 frameworkintegration # provides Qt plugin
69 kauth # provides helper service
70 kcoreaddons # provides extra mime type info
71 kded # provides helper service
72 kfilemetadata # provides Qt plugins
73 kguiaddons # provides geo URL handlers
74 kiconthemes # provides Qt plugins
75 kimageformats # provides Qt plugins
76 qtimageformats # provides optional image formats such as .webp and .avif
77 kio # provides helper service + a bunch of other stuff
78 kio-admin # managing files as admin
79 kio-extras # stuff for MTP, AFC, etc
80 kio-fuse # fuse interface for KIO
81 kpackage # provides kpackagetool tool
82 kservice # provides kbuildsycoca6 tool
83 kunifiedpush # provides a background service and a KCM
84 kwallet # provides helper service
85 kwallet-pam # provides helper service
86 kwalletmanager # provides KCMs and stuff
87 plasma-activities # provides plasma-activities-cli tool
88 solid # provides solid-hardware6 tool
89 phonon-vlc # provides Phonon plugin
98 kglobalacceld # keyboard shortcut daemon
99 kwrited # wall message proxy, not to be confused with kwrite
100 baloo # system indexer
101 milou # search engine atop baloo
102 kdegraphics-thumbnailers # pdf etc thumbnailer
103 polkit-kde-agent-1 # polkit auth ui
106 drkonqi # crash handler
107 kde-inotify-survey # warns the user on low inotifywatch limits
109 # Application integration
110 libplasma # provides Kirigami platform theme
111 plasma-integration # provides Qt platform theme
112 kde-gtk-config # syncs KDE settings to GTK
119 plasma-workspace-wallpapers
120 pkgs.hicolor-icon-theme # fallback icons
126 pkgs.xdg-user-dirs # recommended upstream
138 plasma-browser-integration
140 (lib.getBin qttools) # Expose qdbus in PATH
148 baloo-widgets # baloo information in Dolphin
153 xwaylandvideobridge # exposes Wayland windows to X11 screen capture
154 ] ++ lib.optionals config.services.flatpak.enable [
155 # Since PackageKit Nix support is not there yet,
156 # only install discover if flatpak is enabled.
161 ++ utils.removePackagesByName optionalPackages config.environment.plasma6.excludePackages
162 ++ lib.optionals config.services.desktopManager.plasma6.enableQt5Integration [
164 plasma-integration.qt5
165 pkgs.plasma5Packages.kwayland-integration
167 # Only symlink the KIO plugins, so we don't accidentally pull any services
168 # like KCMs or kcookiejar
170 kioPluginPath = "${pkgs.plasma5Packages.qtbase.qtPluginPrefix}/kf5/kio";
171 inherit (pkgs.plasma5Packages) kio;
172 in pkgs.runCommand "kio5-plugins-only" {} ''
173 mkdir -p $out/${kioPluginPath}
174 ln -s ${kio}/${kioPluginPath}/* $out/${kioPluginPath}
179 # Optional and hardware support features
180 ++ lib.optionals config.hardware.bluetooth.enable [bluedevil bluez-qt pkgs.openobex pkgs.obexftp]
181 ++ lib.optional config.networking.networkmanager.enable plasma-nm
182 ++ lib.optional config.hardware.pulseaudio.enable plasma-pa
183 ++ lib.optional config.services.pipewire.pulse.enable plasma-pa
184 ++ lib.optional config.powerManagement.enable powerdevil
185 ++ lib.optional config.services.printing.enable print-manager
186 ++ lib.optional config.services.colord.enable colord-kde
187 ++ lib.optional config.services.hardware.bolt.enable plasma-thunderbolt
188 ++ lib.optional config.services.samba.enable kdenetwork-filesharing
189 ++ lib.optional config.services.xserver.wacom.enable wacomtablet
190 ++ lib.optional config.services.flatpak.enable flatpak-kcm;
192 environment.pathsToLink = [
193 # FIXME: modules should link subdirs of `/share` rather than relying on this
195 "/libexec" # for drkonqi
198 environment.etc."X11/xkb".source = config.services.xserver.xkb.dir;
200 # Add ~/.config/kdedefaults to XDG_CONFIG_DIRS for shells, since Plasma sets that.
201 # FIXME: maybe we should append to XDG_CONFIG_DIRS in /etc/set-environment instead?
202 environment.sessionVariables.XDG_CONFIG_DIRS = ["$HOME/.config/kdedefaults"];
204 # Needed for things that depend on other store.kde.org packages to install correctly,
205 # notably Plasma look-and-feel packages (a.k.a. Global Themes)
207 # FIXME: this is annoyingly impure and should really be fixed at source level somehow,
208 # but kpackage is a library so we can't just wrap the one thing invoking it and be done.
209 # This also means things won't work for people not on Plasma, but at least this way it
210 # works for SOME people.
211 environment.sessionVariables.KPACKAGE_DEP_RESOLVERS_PATH = "${kdePackages.frameworkintegration.out}/libexec/kf6/kpackagehandlers";
213 # Enable GTK applications to load SVG icons
214 programs.gdk-pixbuf.modulePackages = [pkgs.librsvg];
216 fonts.packages = [cfg.notoPackage pkgs.hack-font];
217 fonts.fontconfig.defaultFonts = {
218 monospace = ["Hack" "Noto Sans Mono"];
219 sansSerif = ["Noto Sans"];
220 serif = ["Noto Serif"];
223 programs.gnupg.agent.pinentryPackage = mkDefault pkgs.pinentry-qt;
224 programs.kde-pim.enable = mkDefault true;
225 programs.ssh.askPassword = mkDefault "${kdePackages.ksshaskpass.out}/bin/ksshaskpass";
227 # Enable helpful DBus services.
228 services.accounts-daemon.enable = true;
229 # when changing an account picture the accounts-daemon reads a temporary file containing the image which systemsettings5 may place under /tmp
230 systemd.services.accounts-daemon.serviceConfig.PrivateTmp = false;
232 services.power-profiles-daemon.enable = mkDefault true;
233 services.system-config-printer.enable = mkIf config.services.printing.enable (mkDefault true);
234 services.udisks2.enable = true;
235 services.upower.enable = config.powerManagement.enable;
236 services.libinput.enable = mkDefault true;
238 # Extra UDEV rules used by Solid
239 services.udev.packages = [
240 # libmtp has "bin", "dev", "out" outputs. UDEV rules file is in "out".
242 pkgs.media-player-info
245 # Set up Dr. Konqi as crash handler
246 systemd.packages = [kdePackages.drkonqi];
247 systemd.services."drkonqi-coredump-processor@".wantedBy = ["systemd-coredump@.service"];
249 xdg.icons.enable = true;
250 xdg.icons.fallbackCursorThemes = mkDefault ["breeze_cursors"];
252 xdg.portal.enable = true;
253 xdg.portal.extraPortals = [
255 kdePackages.xdg-desktop-portal-kde
256 pkgs.xdg-desktop-portal-gtk
258 xdg.portal.configPackages = mkDefault [kdePackages.plasma-workspace];
259 services.pipewire.enable = mkDefault true;
261 # Enable screen reader by default
262 services.orca.enable = mkDefault true;
264 services.displayManager = {
265 sessionPackages = [kdePackages.plasma-workspace];
266 defaultSession = mkDefault "plasma";
268 services.displayManager.sddm = {
269 package = kdePackages.sddm;
270 theme = mkDefault "breeze";
271 wayland.compositor = "kwin";
272 extraPackages = with kdePackages; [
282 security.pam.services = {
285 package = kdePackages.kwallet-pam;
288 allowNullPassword = true;
291 package = kdePackages.kwallet-pam;
294 kde-fingerprint = lib.mkIf config.services.fprintd.enable { fprintAuth = true; };
295 kde-smartcard = lib.mkIf config.security.pam.p11.enable { p11Auth = true; };
298 security.wrappers = {
302 capabilities = "cap_sys_nice+ep";
303 source = "${lib.getBin pkgs.kdePackages.kwin}/bin/kwin_wayland";
307 programs.dconf.enable = true;
309 programs.firefox.nativeMessagingHosts.packages = [kdePackages.plasma-browser-integration];
311 programs.chromium = {
312 enablePlasmaBrowserIntegration = true;
313 plasmaBrowserIntegrationPackage = pkgs.kdePackages.plasma-browser-integration;
316 programs.kdeconnect.package = kdePackages.kdeconnect-kde;
317 programs.partition-manager.package = kdePackages.partitionmanager;
319 # FIXME: ugly hack. See #292632 for details.
320 system.userActivationScripts.rebuildSycoca = activationScript;
321 systemd.user.services.nixos-rebuild-sycoca = {
322 description = "Rebuild KDE system configuration cache";
323 wantedBy = [ "graphical-session-pre.target" ];
324 serviceConfig.Type = "oneshot";
325 script = activationScript;