Difference between revisions of "KDE"

From NixOS Wiki
Jump to: navigation, search
(Add Troubleshoot for Bluetooh)
(Major: Updated document for NixOS 25.05, KDE Plasma 6, Wayland, and RDP service for VMs.)
Line 1: Line 1:
 
KDE Plasma is a desktop environment that aims to be simple by default, powerful when needed.
 
KDE Plasma is a desktop environment that aims to be simple by default, powerful when needed.
 +
 +
''Note: As of 2024, KDE Plasma 5 is end of life and X11 is deprecated. In general you should aim for KDE Plasma 6 and Wayland.''
  
 
== Installation ==
 
== Installation ==
  
To use KDE Plasma 6 on 24.05, add this to your configuration.nix:
+
To use KDE Plasma 6 on a desktop/laptop/VM running 25.05 or later, add this to your configuration.nix:
  
 
<syntaxHighlight lang=nix>
 
<syntaxHighlight lang=nix>
services.xserver.enable = true;
+
services = {
services.displayManager.sddm.enable = true;
+
  desktopManager.plasma6.enable = true;
services.desktopManager.plasma6.enable = true;
 
  
 +
  displayManager.sddm.enable = true;
 +
 +
  displayManager.sddm.wayland = enable = true;
 +
};
 +
 +
environment.systemPackages = with pkgs;
 +
  [
 +
    kdePackages.discover # Optional: Install if you use Flatpak or fwupd firmware update sevice
 +
    kdePackages.kcalc # Calculator
 +
    kdePackages.kcharselect # Tool to select and copy special characters from all installed fonts
 +
    kdePackages.kcolorchooser # A small utility to select a color
 +
    kdePackages.kolourpaint # Easy-to-use paint program
 +
    kdePackages.ksystemlog # KDE SystemLog Application
 +
    kdePackages.sddm-kcm # Configuration module for SDDM
 +
    kdiff3 # Compares and merges 2 or 3 files or directories
 +
    kdePackages.isoimagewriter # Optional: Program to write hybrid ISO files onto USB disks
 +
    kdePackages.partitionmanager # Optional Manage the disk devices, partitions and file systems on your computer
 +
    hardinfo2 # System information and benchmarks for Linux systems
 +
    wayland-utils # Wayland utilities
 +
    wl-clipboard # Command-line copy/paste utilities for Wayland
 +
  ];
 
</syntaxHighlight>
 
</syntaxHighlight>
  
To use KDE Plasma 5 on 24.05, add this to your configuration.nix:
+
To use KDE Plasma 6 on a VM with RDP remote desktop access running 25.05 or later, add this to your configuration.nix. After applying the configuration, you can connect to the VM's GUI desktop from another computer with an RDP client such as Remmina or Microsoft's Windows app. (As of May 2025, the xrdp service still requires X11 instead of Wayland.)
  
 
<syntaxHighlight lang=nix>
 
<syntaxHighlight lang=nix>
services.xserver.enable = true;
+
services = {
# You may need to comment out "services.displayManager.gdm.enable = true;"
+
  desktopManager.plasma6.enable = true;
services.displayManager.sddm.enable = true;
 
services.xserver.desktopManager.plasma5.enable = true;
 
  
</syntaxHighlight>
+
  displayManager.sddm.enable = true;
  
=== Excluding some KDE Plasma applications from the default install ===
+
  xrdp = {
 +
    defaultWindowManager = "startplasma-x11";
 +
    enable = true;
 +
    openFirewall = true;
 +
  };
  
==== Plasma 5 ====
+
  xserver = lib.mkIf isQemu {
 +
    enable = true;
  
Not all applications that come pre-installed with the KDE Plasma desktop environment are desirable for everyone to have on their machines. There's a way to edit configuration.nix to exclude some [https://github.com/NixOS/nixpkgs/blob/nixos-23.11/nixos/modules/services/x11/desktop-managers/plasma5.nix#L275-L284 optional packages], for example as follows:
+
    xkb = {
 +
      layout = "us";
 +
      variant = "";
 +
    };
 +
  };
 +
};
  
<syntaxHighlight lang=nix>
+
environment.systemPackages = with pkgs;
environment.plasma5.excludePackages = with pkgs.libsForQt5; [
+
  [
  plasma-browser-integration
+
    # KDE
  konsole
+
    kdePackages.discover # Optional: Install if you use Flatpak or fwupd firmware update sevice
   oxygen
+
    kdePackages.kcalc # Calculator
];
+
    kdePackages.kcharselect # Tool to select and copy special characters from all installed fonts
 +
    kdePackages.kcolorchooser # A small utility to select a color
 +
    kdePackages.kolourpaint # Easy-to-use paint program
 +
    kdePackages.ksystemlog # KDE SystemLog Application
 +
    kdePackages.sddm-kcm # Configuration module for SDDM
 +
    kdiff3 # Compares and merges 2 or 3 files or directories
 +
    hardinfo2 # System information and benchmarks for Linux systems
 +
    xclip # Tool to access the X clipboard from a console application
 +
   ];
 
</syntaxHighlight>
 
</syntaxHighlight>
  
==== Plasma 6 ====
+
=== Excluding some KDE Plasma applications from the default install ===
  
 
<syntaxHighlight lang=nix>
 
<syntaxHighlight lang=nix>
Line 77: Line 115:
 
For more details, see [https://discourse.nixos.org/t/guide-to-installing-qt-theme/35523/2 this] forum post.
 
For more details, see [https://discourse.nixos.org/t/guide-to-installing-qt-theme/35523/2 this] forum post.
  
== Troubleshoots ==
+
== Troubleshooting ==
  
 
=== No Sound switching from Gnome ===
 
=== No Sound switching from Gnome ===
  
Gnome module has pulseaudio enabled, while Plasma will run without sound. So an additional step would be to enable pulseaudio or pipewire
+
The NixOS Gnome module enables audio by default. For KDE Plasma you must enable audio yourself.
  
 
<syntaxHighlight lang=nix>
 
<syntaxHighlight lang=nix>
  hardware.pulseaudio.enable = true;
+
hardware.pulseaudio.enable = false; # Use Pipewire, the modern sound subsystem
 +
 
 +
security.rtkit.enable = true; # Enable RealtimeKit for audio purposes
 +
 
 +
services.pipewire = {
 +
  enable = true;
 +
  alsa.enable = true;
 +
  alsa.support32Bit = true;
 +
  pulse.enable = true;
 +
  # Uncomment the following line if you want to use JACK applications
 +
  # jack.enable = true;
 +
};
 
</syntaxHighlight>
 
</syntaxHighlight>
  
Line 119: Line 168:
  
 
[https://github.com/NixOS/nixpkgs/issues/160599 (See this issue)]
 
[https://github.com/NixOS/nixpkgs/issues/160599 (See this issue)]
 
=== Launch KDE in Wayland session ===
 
 
==== Plasma 6 ====
 
 
For KDE Plasma 6, the defaults have changed. KDE Plasma 6 runs on Wayland with the default session set to <code>plasma</code>.
 
If you want to use the X11 session as your default session, change it to <code>plasmax11</code>.
 
<syntaxHighlight lang=nix>
 
services.displayManager.defaultSession = "plasma";
 
</syntaxHighlight>
 
 
==== Launch SDDM in Wayland too ====
 
 
It's possible to launch sddm in Wayland too to try to avoid running an X server.
 
 
<syntaxHighlight lang=nix>
 
services.displayManager.sddm.wayland.enable = true;
 
</syntaxHighlight>
 
  
 
=== Plasma-Manager ===
 
=== Plasma-Manager ===
Line 144: Line 175:
 
With [https://github.com/pjones/plasma-manager plasma-manager], it is possible to make Plasma configurations via nix by providing [https://github.com/nix-community/home-manager home-manager] modules.  
 
With [https://github.com/pjones/plasma-manager plasma-manager], it is possible to make Plasma configurations via nix by providing [https://github.com/nix-community/home-manager home-manager] modules.  
  
=== Bluetooth configuration not available ===
+
=== Bluetooth not available ===
  
 
Add the following configuration (generally in harwdare-configuration.nix):
 
Add the following configuration (generally in harwdare-configuration.nix):
  
 
<syntaxHighlight lang=nix>
 
<syntaxHighlight lang=nix>
hardware.bluetooth.enable = true;
+
hardware.bluetooth = {
</syntaxHighlight>
+
  enable = true;
 
+
  powerOnBoot = true;
This will add the following packages:
+
};
 
 
<syntaxHighlight lang=nix>
 
[
 
bluedevil
 
bluez-qt
 
pkgs.openobex
 
pkgs.obexftp
 
]
 
 
</syntaxHighlight>
 
</syntaxHighlight>
  
 
[[Category:Desktop environment]]
 
[[Category:Desktop environment]]
 
[[Category:Applications]]
 
[[Category:Applications]]

Revision as of 03:55, 23 May 2025

KDE Plasma is a desktop environment that aims to be simple by default, powerful when needed.

Note: As of 2024, KDE Plasma 5 is end of life and X11 is deprecated. In general you should aim for KDE Plasma 6 and Wayland.

Installation

To use KDE Plasma 6 on a desktop/laptop/VM running 25.05 or later, add this to your configuration.nix:

services = {
  desktopManager.plasma6.enable = true;

  displayManager.sddm.enable = true;

  displayManager.sddm.wayland = enable = true;
};

environment.systemPackages = with pkgs;
  [
    kdePackages.discover # Optional: Install if you use Flatpak or fwupd firmware update sevice
    kdePackages.kcalc # Calculator
    kdePackages.kcharselect # Tool to select and copy special characters from all installed fonts
    kdePackages.kcolorchooser # A small utility to select a color
    kdePackages.kolourpaint # Easy-to-use paint program
    kdePackages.ksystemlog # KDE SystemLog Application
    kdePackages.sddm-kcm # Configuration module for SDDM
    kdiff3 # Compares and merges 2 or 3 files or directories
    kdePackages.isoimagewriter # Optional: Program to write hybrid ISO files onto USB disks
    kdePackages.partitionmanager # Optional Manage the disk devices, partitions and file systems on your computer
    hardinfo2 # System information and benchmarks for Linux systems
    wayland-utils # Wayland utilities
    wl-clipboard # Command-line copy/paste utilities for Wayland
  ];

To use KDE Plasma 6 on a VM with RDP remote desktop access running 25.05 or later, add this to your configuration.nix. After applying the configuration, you can connect to the VM's GUI desktop from another computer with an RDP client such as Remmina or Microsoft's Windows app. (As of May 2025, the xrdp service still requires X11 instead of Wayland.)

services = {
  desktopManager.plasma6.enable = true;

  displayManager.sddm.enable = true;

  xrdp = {
    defaultWindowManager = "startplasma-x11";
    enable = true;
    openFirewall = true;
  };

  xserver = lib.mkIf isQemu {
    enable = true;

    xkb = {
      layout = "us";
      variant = "";
    };
  };
};

environment.systemPackages = with pkgs;
  [
    # KDE
    kdePackages.discover # Optional: Install if you use Flatpak or fwupd firmware update sevice
    kdePackages.kcalc # Calculator
    kdePackages.kcharselect # Tool to select and copy special characters from all installed fonts
    kdePackages.kcolorchooser # A small utility to select a color
    kdePackages.kolourpaint # Easy-to-use paint program
    kdePackages.ksystemlog # KDE SystemLog Application
    kdePackages.sddm-kcm # Configuration module for SDDM
    kdiff3 # Compares and merges 2 or 3 files or directories
    hardinfo2 # System information and benchmarks for Linux systems
    xclip # Tool to access the X clipboard from a console application
  ];

Excluding some KDE Plasma applications from the default install

environment.plasma6.excludePackages = with pkgs.kdePackages; [
  plasma-browser-integration
  konsole
  oxygen
];

Configuration

GNOME desktop integration

Using the following example configuration, QT applications will have a look similar to the GNOME desktop, using a dark theme.

qt = {
  enable = true;
  platformTheme = "gnome";
  style = "adwaita-dark";
};

For other themes, you may need the packages libsForQt5.qt5ct and libsForQt5.qtstyleplugin-kvantum and a symlink from ~/.config/Kvantum/ to your theme package. Here is an example using Arc-Dark and Home Manager. In the Home Manager configuration:

qt = {
  enable = true;
  platformTheme = "qtct";
  style.name = "kvantum";
};

xdg.configFile = {
  "Kvantum/ArcDark".source = "${pkgs.arc-kde-theme}/share/Kvantum/ArcDark";
  "Kvantum/kvantum.kvconfig".text = "[General]\ntheme=ArcDark";
};

For more details, see this forum post.

Troubleshooting

No Sound switching from Gnome

The NixOS Gnome module enables audio by default. For KDE Plasma you must enable audio yourself.

hardware.pulseaudio.enable = false; # Use Pipewire, the modern sound subsystem

security.rtkit.enable = true; # Enable RealtimeKit for audio purposes

services.pipewire = {
  enable = true;
  alsa.enable = true;
  alsa.support32Bit = true;
  pulse.enable = true;
  # Uncomment the following line if you want to use JACK applications
  # jack.enable = true;
};

Qt/KDE applications segfault on start

This is caused by a stale QML cache (see this issue). A dirty way to fix this is by running on a terminal the following command:

find ${XDG_CACHE_HOME:-$HOME/.cache}/**/qmlcache -type f -delete

GTK themes are not applied in Wayland applications / Window Decorations missing / Cursor looks different

This affects GTK applications including Firefox and Thunderbird.

Add to your configuration.nix the following line:

programs.dconf.enable = true;

You might also need to set a GTK theme Breeze imitating the KDE theme with the same name in System Settings -> Application Style -->Configure GNOME/GTK Application Style.

(See this issue)

KMail Renders Blank Messages

When you see the message grantlee.template: "Plugin library 'kde_grantlee_plugin' not found." and/or kmail does shows only empty message then add to your configuration.nix the following line:

environment.sessionVariables = {
  NIX_PROFILES = "${pkgs.lib.concatStringsSep " " (pkgs.lib.reverseList config.environment.profiles)}";
};

(See this issue)

Plasma-Manager

Note: Plasma-Manager is not matured yet and currently unofficial

By default, the Plasma configuration can be handled like on traditional systems. With plasma-manager, it is possible to make Plasma configurations via nix by providing home-manager modules.

Bluetooth not available

Add the following configuration (generally in harwdare-configuration.nix):

hardware.bluetooth = {
  enable = true;
  powerOnBoot = true;
};