···
10
-
xcfg = config.services.xserver;
11
-
cfg = xcfg.desktopManager.plasma5;
13
-
# Use only for **internal** options.
14
-
# This is not exactly user-friendly.
15
-
kdeConfigurationType =
26
-
description = "KDE Configuration value";
27
-
emptyValue.value = "";
29
-
set = (nullOr (lazyAttrsOf valueTypes)) // {
30
-
description = "KDE Configuration set";
31
-
emptyValue.value = { };
36
-
description = "KDE Configuration file";
37
-
emptyValue.value = { };
44
-
mkRemovedOptionModule
45
-
mkRenamedOptionModule
54
-
activationScript = ''
55
-
${set_XDG_CONFIG_HOME}
57
-
# The KDE icon cache is supposed to update itself automatically, but it uses
58
-
# the timestamp on the icon theme directory as a trigger. This doesn't work
59
-
# on NixOS because the timestamp never changes. As a workaround, delete the
60
-
# icon cache at login and session activation.
61
-
# See also: http://lists-archives.org/kde-devel/26175-what-when-will-icon-cache-refresh.html
62
-
rm -fv "$HOME"/.cache/icon-cache.kcache
64
-
# xdg-desktop-settings generates this empty file but
65
-
# it makes kbuildsyscoca5 fail silently. To fix this
66
-
# remove that menu if it exists.
67
-
rm -fv "''${XDG_CONFIG_HOME}"/menus/applications-merged/xdg-desktop-menu-dummy.menu
69
-
# Qt writes a weird ‘libraryPath’ line to
70
-
# ~/.config/Trolltech.conf that causes the KDE plugin
71
-
# paths of previous KDE invocations to be searched.
72
-
# Obviously using mismatching KDE libraries is potentially
73
-
# disastrous, so here we nuke references to the Nix store
74
-
# in Trolltech.conf. A better solution would be to stop
75
-
# Qt from doing this wackiness in the first place.
76
-
trolltech_conf="''${XDG_CONFIG_HOME}/Trolltech.conf"
77
-
if [ -e "$trolltech_conf" ]; then
78
-
${getBin pkgs.gnused}/bin/sed -i "$trolltech_conf" -e '/nix\\store\|nix\/store/ d'
81
-
# Remove the kbuildsyscoca5 cache. It will be regenerated
82
-
# immediately after. This is necessary for kbuildsyscoca5 to
83
-
# recognize that software that has been removed.
84
-
rm -fv "$HOME"/.cache/ksycoca*
86
-
${pkgs.plasma5Packages.kservice}/bin/kbuildsycoca5
89
-
set_XDG_CONFIG_HOME = ''
90
-
# Set the default XDG_CONFIG_HOME if it is unset.
91
-
# Per the XDG Base Directory Specification:
92
-
# https://specifications.freedesktop.org/basedir-spec/latest
93
-
# 1. Never export this variable! If it is unset, then child processes are
94
-
# expected to set the default themselves.
95
-
# 2. Contaminate / if $HOME is unset; do not check if $HOME is set.
96
-
XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-$HOME/.config}
103
-
services.xserver.desktopManager.plasma5 = {
104
-
enable = mkOption {
107
-
description = "Enable the Plasma 5 (KDE 5) desktop environment.";
110
-
phononBackend = mkOption {
111
-
type = types.enum [
116
-
example = "gstreamer";
117
-
description = "Phonon audio backend to install.";
120
-
useQtScaling = mkOption {
123
-
description = "Enable HiDPI scaling in Qt.";
126
-
runUsingSystemd = mkOption {
127
-
description = "Use systemd to manage the Plasma session";
132
-
notoPackage = mkPackageOption pkgs "Noto fonts" {
133
-
default = [ "noto-fonts" ];
134
-
example = "noto-fonts-lgc-plus";
137
-
# Internally allows configuring kdeglobals globally
138
-
kdeglobals = mkOption {
141
-
type = kdeConfigurationType;
144
-
# Internally allows configuring kwin globally
145
-
kwinrc = mkOption {
148
-
type = kdeConfigurationType;
151
-
mobile.enable = mkOption {
155
-
Enable support for running the Plasma Mobile shell.
159
-
mobile.installRecommendedSoftware = mkOption {
163
-
Installs software recommended for use with Plasma Mobile, but which
164
-
is not strictly required for Plasma Mobile to run.
168
-
bigscreen.enable = mkOption {
172
-
Enable support for running the Plasma Bigscreen session.
176
-
environment.plasma5.excludePackages = mkOption {
177
-
description = "List of default packages to exclude from the configuration";
178
-
type = types.listOf types.package;
180
-
example = literalExpression "[ pkgs.plasma5Packages.oxygen ]";
185
-
(mkRemovedOptionModule [
191
-
] "Phonon no longer supports Qt 4.")
192
-
(mkRemovedOptionModule [
198
-
] "DDC/CI is no longer supported upstream.")
199
-
(mkRenamedOptionModule
200
-
[ "services" "xserver" "desktopManager" "kde5" ]
201
-
[ "services" "xserver" "desktopManager" "plasma5" ]
203
-
(mkRenamedOptionModule
204
-
[ "services" "xserver" "desktopManager" "plasma5" "excludePackages" ]
205
-
[ "environment" "plasma5" "excludePackages" ]
210
-
# Common Plasma dependencies
211
-
(mkIf (cfg.enable || cfg.mobile.enable || cfg.bigscreen.enable) {
213
-
"Plasma 5 has been deprecated and will be removed in NixOS 25.11. Please migrate your configuration to Plasma 6."
216
-
security.wrappers = {
220
-
capabilities = "cap_sys_nice+ep";
221
-
source = "${getBin pkgs.plasma5Packages.kwin}/bin/kwin_wayland";
224
-
// optionalAttrs (!cfg.runUsingSystemd) {
229
-
source = "${getBin pkgs.plasma5Packages.kinit}/libexec/kf5/start_kdeinit";
235
-
environment.systemPackages =
236
-
with pkgs.plasma5Packages;
238
-
requiredPackages = [
239
-
frameworkintegration
260
-
kirigami2 # In system profile for SDDM theme. TODO: wrapper.
276
-
kwayland-integration
308
-
plasma-workspace-wallpapers
313
-
pkgs.hicolor-icon-theme
320
-
pkgs.xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
322
-
optionalPackages = [
323
-
pkgs.aha # needed by kinfocenter for fwupd support
324
-
plasma-browser-integration
327
-
(lib.getBin qttools) # Expose qdbus in PATH
331
-
++ utils.removePackagesByName optionalPackages config.environment.plasma5.excludePackages
333
-
# Phonon audio backend
334
-
++ lib.optional (cfg.phononBackend == "gstreamer") pkgs.plasma5Packages.phonon-backend-gstreamer
335
-
++ lib.optional (cfg.phononBackend == "vlc") pkgs.plasma5Packages.phonon-backend-vlc
337
-
# Optional hardware support features
338
-
++ lib.optionals config.hardware.bluetooth.enable [
344
-
++ lib.optional config.networking.networkmanager.enable plasma-nm
345
-
++ lib.optional config.services.pulseaudio.enable plasma-pa
346
-
++ lib.optional config.services.pipewire.pulse.enable plasma-pa
347
-
++ lib.optional config.powerManagement.enable powerdevil
348
-
++ lib.optional config.services.colord.enable pkgs.colord-kde
349
-
++ lib.optional config.services.hardware.bolt.enable pkgs.plasma5Packages.plasma-thunderbolt
350
-
++ lib.optional config.services.samba.enable kdenetwork-filesharing
351
-
++ lib.optional config.services.xserver.wacom.enable pkgs.wacomtablet
352
-
++ lib.optional config.services.flatpak.enable flatpak-kcm;
354
-
# Extra services for D-Bus activation
355
-
services.dbus.packages = [
356
-
pkgs.plasma5Packages.kactivitymanagerd
359
-
environment.pathsToLink = [
360
-
# FIXME: modules should link subdirs of `/share` rather than relying on this
364
-
environment.etc."X11/xkb".source = xcfg.xkb.dir;
366
-
environment.sessionVariables = {
367
-
PLASMA_USE_QT_SCALING = mkIf cfg.useQtScaling "1";
369
-
# Needed for things that depend on other store.kde.org packages to install correctly,
370
-
# notably Plasma look-and-feel packages (a.k.a. Global Themes)
372
-
# FIXME: this is annoyingly impure and should really be fixed at source level somehow,
373
-
# but kpackage is a library so we can't just wrap the one thing invoking it and be done.
374
-
# This also means things won't work for people not on Plasma, but at least this way it
375
-
# works for SOME people.
376
-
KPACKAGE_DEP_RESOLVERS_PATH = "${pkgs.plasma5Packages.frameworkintegration.out}/libexec/kf5/kpackagehandlers";
379
-
# Enable GTK applications to load SVG icons
380
-
programs.gdk-pixbuf.modulePackages = [ pkgs.librsvg ];
382
-
fonts.packages = with pkgs; [
386
-
fonts.fontconfig.defaultFonts = {
391
-
sansSerif = [ "Noto Sans" ];
392
-
serif = [ "Noto Serif" ];
395
-
programs.gnupg.agent.pinentryPackage = mkDefault pkgs.pinentry-qt;
396
-
programs.ssh.askPassword = mkDefault "${pkgs.plasma5Packages.ksshaskpass.out}/bin/ksshaskpass";
398
-
# Enable helpful DBus services.
399
-
services.accounts-daemon.enable = true;
400
-
programs.dconf.enable = true;
401
-
# when changing an account picture the accounts-daemon reads a temporary file containing the image which systemsettings5 may place under /tmp
402
-
systemd.services.accounts-daemon.serviceConfig.PrivateTmp = false;
403
-
services.power-profiles-daemon.enable = mkDefault true;
404
-
services.system-config-printer.enable = mkIf config.services.printing.enable (mkDefault true);
405
-
services.udisks2.enable = true;
406
-
services.upower.enable = config.powerManagement.enable;
407
-
services.libinput.enable = mkDefault true;
409
-
# Extra UDEV rules used by Solid
410
-
services.udev.packages = [
411
-
# libmtp has "bin", "dev", "out" outputs. UDEV rules file is in "out".
413
-
pkgs.media-player-info
416
-
# Enable screen reader by default
417
-
services.orca.enable = mkDefault true;
419
-
services.displayManager.sddm = {
420
-
theme = mkDefault "breeze";
423
-
security.pam.services.kde = {
424
-
allowNullPassword = true;
427
-
security.pam.services.login.kwallet.enable = true;
429
-
systemd.user.services = {
430
-
plasma-early-setup = mkIf cfg.runUsingSystemd {
431
-
description = "Early Plasma setup";
432
-
wantedBy = [ "graphical-session-pre.target" ];
433
-
serviceConfig.Type = "oneshot";
434
-
script = activationScript;
438
-
xdg.icons.enable = true;
440
-
xdg.portal.enable = true;
441
-
xdg.portal.extraPortals = [ pkgs.plasma5Packages.xdg-desktop-portal-kde ];
442
-
xdg.portal.configPackages = mkDefault [ pkgs.plasma5Packages.xdg-desktop-portal-kde ];
443
-
# xdg-desktop-portal-kde expects PipeWire to be running.
444
-
services.pipewire.enable = mkDefault true;
446
-
# Update the start menu for each user that is currently logged in
447
-
system.userActivationScripts.plasmaSetup = activationScript;
449
-
programs.firefox.nativeMessagingHosts.packages = [
450
-
pkgs.plasma5Packages.plasma-browser-integration
452
-
programs.chromium.enablePlasmaBrowserIntegration = true;
455
-
(mkIf (cfg.kwinrc != { }) {
456
-
environment.etc."xdg/kwinrc".text = lib.generators.toINI { } cfg.kwinrc;
459
-
(mkIf (cfg.kdeglobals != { }) {
460
-
environment.etc."xdg/kdeglobals".text = lib.generators.toINI { } cfg.kdeglobals;
466
-
# Seed our configuration into nixos-generate-config
467
-
system.nixos-generate-config.desktopConfiguration = [
469
-
# Enable the Plasma 5 Desktop Environment.
470
-
services.displayManager.sddm.enable = true;
471
-
services.xserver.desktopManager.plasma5.enable = true;
475
-
services.displayManager.sessionPackages = [ pkgs.plasma5Packages.plasma-workspace ];
476
-
# Default to be `plasma` (X11) instead of `plasmawayland`, since plasma wayland currently has
478
-
# See: https://github.com/NixOS/nixpkgs/issues/143272
479
-
services.displayManager.defaultSession = mkDefault "plasma";
481
-
environment.systemPackages =
482
-
with pkgs.plasma5Packages;
484
-
requiredPackages = [
488
-
plasma-systemmonitor
495
-
kdegraphics-thumbnailers
500
-
optionalPackages = [
510
-
++ utils.removePackagesByName optionalPackages config.environment.plasma5.excludePackages;
512
-
systemd.user.services = {
513
-
plasma-run-with-systemd = {
514
-
description = "Run KDE Plasma via systemd";
515
-
wantedBy = [ "basic.target" ];
516
-
serviceConfig.Type = "oneshot";
518
-
${set_XDG_CONFIG_HOME}
520
-
${pkgs.plasma5Packages.kconfig}/bin/kwriteconfig5 \
521
-
--file startkderc --group General --key systemdBoot ${lib.boolToString cfg.runUsingSystemd}
528
-
(mkIf cfg.mobile.enable {
531
-
# The user interface breaks without NetworkManager
532
-
assertion = config.networking.networkmanager.enable;
533
-
message = "Plasma Mobile requires NetworkManager.";
536
-
# The user interface breaks without bluetooth
537
-
assertion = config.hardware.bluetooth.enable;
538
-
message = "Plasma Mobile requires Bluetooth.";
541
-
# The user interface breaks without pulse
543
-
config.services.pulseaudio.enable
544
-
|| (config.services.pipewire.enable && config.services.pipewire.pulse.enable);
545
-
message = "Plasma Mobile requires a Pulseaudio compatible sound server.";
549
-
environment.systemPackages =
550
-
with pkgs.plasma5Packages;
552
-
# Basic packages without which Plasma Mobile fails to work properly.
555
-
pkgs.maliit-framework
556
-
pkgs.maliit-keyboard
558
-
++ lib.optionals (cfg.mobile.installRecommendedSoftware) (
559
-
with pkgs.plasma5Packages.plasmaMobileGear;
561
-
# Additional software made for Plasma Mobile.
581
-
# The following services are needed or the UI is broken.
582
-
hardware.bluetooth.enable = true;
583
-
networking.networkmanager.enable = true;
584
-
# Required for autorotate
585
-
hardware.sensor.iio.enable = lib.mkDefault true;
587
-
# Recommendations can be found here:
588
-
# - https://invent.kde.org/plasma-mobile/plasma-phone-settings/-/tree/master/etc/xdg
589
-
# This configuration is the minimum required for Plasma Mobile to *work*.
590
-
services.xserver.desktopManager.plasma5 = {
593
-
# This forces a numeric PIN for the lockscreen, which is the
594
-
# recommendation from upstream.
595
-
LookAndFeelPackage = lib.mkDefault "org.kde.plasma.phone";
600
-
"InputMethod[$e]" = "/run/current-system/sw/share/applications/com.github.maliit.keyboard.desktop";
601
-
"VirtualKeyboardEnabled" = "true";
603
-
"org.kde.kdecoration2" = {
604
-
# No decorations (title bar)
605
-
NoPlugin = lib.mkDefault "true";
610
-
services.displayManager.sessionPackages = [ pkgs.plasma5Packages.plasma-mobile ];
614
-
(mkIf cfg.bigscreen.enable {
615
-
environment.systemPackages = with pkgs.plasma5Packages; [
619
-
plasma-remotecontrollers
629
-
services.displayManager.sessionPackages = [ pkgs.plasma5Packages.plasma-bigscreen ];
631
-
# required for plasma-remotecontrollers to work correctly
632
-
hardware.uinput.enable = true;