1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
|
{
config,
lib,
pkgs,
utils,
...
}: let
cfg = config.services.desktopManager.plasma6;
inherit (pkgs) kdePackages;
inherit (lib) literalExpression mkDefault mkIf mkOption mkPackageOption types;
activationScript = ''
# will be rebuilt automatically
rm -fv $HOME/.cache/ksycoca*
'';
in {
options = {
services.desktopManager.plasma6 = {
enable = mkOption {
type = types.bool;
default = false;
description = "Enable the Plasma 6 (KDE 6) desktop environment.";
};
enableQt5Integration = mkOption {
type = types.bool;
default = true;
description = "Enable Qt 5 integration (theming, etc). Disable for a pure Qt 6 system.";
};
notoPackage = mkPackageOption pkgs "Noto fonts - used for UI by default" {
default = ["noto-fonts"];
example = "noto-fonts-lgc-plus";
};
};
environment.plasma6.excludePackages = mkOption {
description = "List of default packages to exclude from the configuration";
type = types.listOf types.package;
default = [];
example = literalExpression "[ pkgs.kdePackages.elisa ]";
};
};
imports = [
(lib.mkRenamedOptionModule [ "services" "xserver" "desktopManager" "plasma6" "enable" ] [ "services" "desktopManager" "plasma6" "enable" ])
(lib.mkRenamedOptionModule [ "services" "xserver" "desktopManager" "plasma6" "enableQt5Integration" ] [ "services" "desktopManager" "plasma6" "enableQt5Integration" ])
(lib.mkRenamedOptionModule [ "services" "xserver" "desktopManager" "plasma6" "notoPackage" ] [ "services" "desktopManager" "plasma6" "notoPackage" ])
];
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.enable -> !config.services.xserver.desktopManager.plasma5.enable;
message = "Cannot enable plasma5 and plasma6 at the same time!";
}
];
qt.enable = true;
environment.systemPackages = with kdePackages; let
requiredPackages = [
qtwayland # Hack? To make everything run on Wayland
qtsvg # Needed to render SVG icons
# Frameworks with globally loadable bits
frameworkintegration # provides Qt plugin
kauth # provides helper service
kcoreaddons # provides extra mime type info
kded # provides helper service
kfilemetadata # provides Qt plugins
kguiaddons # provides geo URL handlers
kiconthemes # provides Qt plugins
kimageformats # provides Qt plugins
kio # provides helper service + a bunch of other stuff
kio-admin # managing files as admin
kio-extras # stuff for MTP, AFC, etc
kio-fuse # fuse interface for KIO
kpackage # provides kpackagetool tool
kservice # provides kbuildsycoca6 tool
kwallet # provides helper service
kwallet-pam # provides helper service
kwalletmanager # provides KCMs and stuff
plasma-activities # provides plasma-activities-cli tool
solid # provides solid-hardware6 tool
phonon-vlc # provides Phonon plugin
# Core Plasma parts
kwin
pkgs.xwayland
kscreen
libkscreen
kscreenlocker
kactivitymanagerd
kde-cli-tools
kglobalacceld # keyboard shortcut daemon
kwrited # wall message proxy, not to be confused with kwrite
baloo # system indexer
milou # search engine atop baloo
kdegraphics-thumbnailers # pdf etc thumbnailer
polkit-kde-agent-1 # polkit auth ui
plasma-desktop
plasma-workspace
drkonqi # crash handler
kde-inotify-survey # warns the user on low inotifywatch limits
# Application integration
libplasma # provides Kirigami platform theme
plasma-integration # provides Qt platform theme
kde-gtk-config # syncs KDE settings to GTK
# Artwork + themes
breeze
breeze-icons
breeze-gtk
ocean-sound-theme
plasma-workspace-wallpapers
pkgs.hicolor-icon-theme # fallback icons
qqc2-breeze-style
qqc2-desktop-style
# misc Plasma extras
kdeplasma-addons
pkgs.xdg-user-dirs # recommended upstream
# Plasma utilities
kmenuedit
kinfocenter
plasma-systemmonitor
ksystemstats
libksysguard
systemsettings
kcmutils
];
optionalPackages = [
plasma-browser-integration
konsole
(lib.getBin qttools) # Expose qdbus in PATH
ark
elisa
gwenview
okular
kate
khelpcenter
dolphin
dolphin-plugins
spectacle
ffmpegthumbs
krdp
] ++ lib.optionals config.services.flatpak.enable [
# Since PackageKit Nix support is not there yet,
# only install discover if flatpak is enabled.
discover
];
in
requiredPackages
++ utils.removePackagesByName optionalPackages config.environment.plasma6.excludePackages
++ lib.optionals config.services.desktopManager.plasma6.enableQt5Integration [
breeze.qt5
plasma-integration.qt5
pkgs.plasma5Packages.kwayland-integration
(
# Only symlink the KIO plugins, so we don't accidentally pull any services
# like KCMs or kcookiejar
let
kioPluginPath = "${pkgs.plasma5Packages.qtbase.qtPluginPrefix}/kf5/kio";
inherit (pkgs.plasma5Packages) kio;
in pkgs.runCommand "kio5-plugins-only" {} ''
mkdir -p $out/${kioPluginPath}
ln -s ${kio}/${kioPluginPath}/* $out/${kioPluginPath}
''
)
kio-extras-kf5
]
# Optional and hardware support features
++ lib.optionals config.hardware.bluetooth.enable [bluedevil bluez-qt pkgs.openobex pkgs.obexftp]
++ lib.optional config.networking.networkmanager.enable plasma-nm
++ lib.optional config.hardware.pulseaudio.enable plasma-pa
++ lib.optional config.services.pipewire.pulse.enable plasma-pa
++ lib.optional config.powerManagement.enable powerdevil
++ lib.optional config.services.printing.enable print-manager
++ lib.optional config.services.colord.enable colord-kde
++ lib.optional config.services.hardware.bolt.enable plasma-thunderbolt
++ lib.optional config.services.samba.enable kdenetwork-filesharing
++ lib.optional config.services.xserver.wacom.enable wacomtablet
++ lib.optional config.services.flatpak.enable flatpak-kcm;
environment.pathsToLink = [
# FIXME: modules should link subdirs of `/share` rather than relying on this
"/share"
"/libexec" # for drkonqi
];
environment.etc."X11/xkb".source = config.services.xserver.xkb.dir;
# Add ~/.config/kdedefaults to XDG_CONFIG_DIRS for shells, since Plasma sets that.
# FIXME: maybe we should append to XDG_CONFIG_DIRS in /etc/set-environment instead?
environment.sessionVariables.XDG_CONFIG_DIRS = ["$HOME/.config/kdedefaults"];
# Needed for things that depend on other store.kde.org packages to install correctly,
# notably Plasma look-and-feel packages (a.k.a. Global Themes)
#
# FIXME: this is annoyingly impure and should really be fixed at source level somehow,
# but kpackage is a library so we can't just wrap the one thing invoking it and be done.
# This also means things won't work for people not on Plasma, but at least this way it
# works for SOME people.
environment.sessionVariables.KPACKAGE_DEP_RESOLVERS_PATH = "${kdePackages.frameworkintegration.out}/libexec/kf6/kpackagehandlers";
# Enable GTK applications to load SVG icons
programs.gdk-pixbuf.modulePackages = [pkgs.librsvg];
fonts.packages = [cfg.notoPackage pkgs.hack-font];
fonts.fontconfig.defaultFonts = {
monospace = ["Hack" "Noto Sans Mono"];
sansSerif = ["Noto Sans"];
serif = ["Noto Serif"];
};
programs.gnupg.agent.pinentryPackage = mkDefault pkgs.pinentry-qt;
programs.kde-pim.enable = mkDefault true;
programs.ssh.askPassword = mkDefault "${kdePackages.ksshaskpass.out}/bin/ksshaskpass";
# Enable helpful DBus services.
services.accounts-daemon.enable = true;
# when changing an account picture the accounts-daemon reads a temporary file containing the image which systemsettings5 may place under /tmp
systemd.services.accounts-daemon.serviceConfig.PrivateTmp = false;
services.power-profiles-daemon.enable = mkDefault true;
services.system-config-printer.enable = mkIf config.services.printing.enable (mkDefault true);
services.udisks2.enable = true;
services.upower.enable = config.powerManagement.enable;
services.libinput.enable = mkDefault true;
# Extra UDEV rules used by Solid
services.udev.packages = [
# libmtp has "bin", "dev", "out" outputs. UDEV rules file is in "out".
pkgs.libmtp.out
pkgs.media-player-info
];
# Set up Dr. Konqi as crash handler
systemd.packages = [kdePackages.drkonqi];
systemd.services."drkonqi-coredump-processor@".wantedBy = ["systemd-coredump@.service"];
xdg.icons.enable = true;
xdg.portal.enable = true;
xdg.portal.extraPortals = [
kdePackages.xdg-desktop-portal-kde
pkgs.xdg-desktop-portal-gtk
];
xdg.portal.configPackages = mkDefault [kdePackages.xdg-desktop-portal-kde];
services.pipewire.enable = mkDefault true;
# Enable screen reader by default
services.orca.enable = mkDefault true;
services.displayManager = {
sessionPackages = [kdePackages.plasma-workspace];
defaultSession = mkDefault "plasma";
};
services.displayManager.sddm = {
package = kdePackages.sddm;
theme = mkDefault "breeze";
wayland.compositor = "kwin";
extraPackages = with kdePackages; [
breeze-icons
kirigami
libplasma
plasma5support
qtsvg
qtvirtualkeyboard
];
};
security.pam.services = {
login.kwallet = {
enable = true;
package = kdePackages.kwallet-pam;
};
kde = {
allowNullPassword = true;
kwallet = {
enable = true;
package = kdePackages.kwallet-pam;
};
};
kde-fingerprint = lib.mkIf config.services.fprintd.enable { fprintAuth = true; };
kde-smartcard = lib.mkIf config.security.pam.p11.enable { p11Auth = true; };
};
security.wrappers = {
kwin_wayland = {
owner = "root";
group = "root";
capabilities = "cap_sys_nice+ep";
source = "${lib.getBin pkgs.kdePackages.kwin}/bin/kwin_wayland";
};
};
programs.dconf.enable = true;
programs.firefox.nativeMessagingHosts.packages = [kdePackages.plasma-browser-integration];
programs.chromium = {
enablePlasmaBrowserIntegration = true;
plasmaBrowserIntegrationPackage = pkgs.kdePackages.plasma-browser-integration;
};
programs.kdeconnect.package = kdePackages.kdeconnect-kde;
programs.partition-manager.package = kdePackages.partitionmanager;
# FIXME: ugly hack. See #292632 for details.
system.userActivationScripts.rebuildSycoca = activationScript;
systemd.user.services.nixos-rebuild-sycoca = {
description = "Rebuild KDE system configuration cache";
wantedBy = [ "graphical-session-pre.target" ];
serviceConfig.Type = "oneshot";
script = activationScript;
};
};
}
|