about summary refs log tree commit diff
path: root/pkgs/desktops/plasma-5
diff options
context:
space:
mode:
authorThomas Tuegel <ttuegel@mailbox.org>2017-02-25 13:35:00 -0600
committerThomas Tuegel <ttuegel@mailbox.org>2017-02-27 11:49:12 -0600
commit7f84ad5f4c4a2aac98ebb2f4a37a02915e357939 (patch)
tree2b2777319ca8bd22e5e5797f51ad91df0a5cd0f8 /pkgs/desktops/plasma-5
parent8eb4d2afbc1d61d316073f25f5885a46ccb37ea2 (diff)
plasma5: Move to desktops/plasma-5
Diffstat (limited to 'pkgs/desktops/plasma-5')
-rw-r--r--pkgs/desktops/plasma-5/bluedevil.nix19
-rw-r--r--pkgs/desktops/plasma-5/breeze-grub.nix16
-rw-r--r--pkgs/desktops/plasma-5/breeze-gtk.nix9
-rw-r--r--pkgs/desktops/plasma-5/breeze-plymouth/default.nix16
-rw-r--r--pkgs/desktops/plasma-5/breeze-plymouth/install-paths.patch19
-rw-r--r--pkgs/desktops/plasma-5/breeze-plymouth/series1
-rw-r--r--pkgs/desktops/plasma-5/breeze-qt4.nix24
-rw-r--r--pkgs/desktops/plasma-5/breeze-qt5.nix17
-rw-r--r--pkgs/desktops/plasma-5/default.nix101
-rw-r--r--pkgs/desktops/plasma-5/fetch.sh1
-rw-r--r--pkgs/desktops/plasma-5/kactivitymanagerd.nix14
-rw-r--r--pkgs/desktops/plasma-5/kde-cli-tools.nix14
-rw-r--r--pkgs/desktops/plasma-5/kde-gtk-config/0001-follow-symlinks.patch52
-rw-r--r--pkgs/desktops/plasma-5/kde-gtk-config/default.nix27
-rw-r--r--pkgs/desktops/plasma-5/kdecoration.nix6
-rw-r--r--pkgs/desktops/plasma-5/kdeplasma-addons.nix20
-rw-r--r--pkgs/desktops/plasma-5/kgamma5.nix9
-rw-r--r--pkgs/desktops/plasma-5/khotkeys.nix22
-rw-r--r--pkgs/desktops/plasma-5/kinfocenter.nix17
-rw-r--r--pkgs/desktops/plasma-5/kmenuedit.nix14
-rw-r--r--pkgs/desktops/plasma-5/kscreen.nix13
-rw-r--r--pkgs/desktops/plasma-5/kscreenlocker.nix15
-rw-r--r--pkgs/desktops/plasma-5/ksshaskpass.nix9
-rw-r--r--pkgs/desktops/plasma-5/ksysguard.nix17
-rw-r--r--pkgs/desktops/plasma-5/kwallet-pam.nix11
-rw-r--r--pkgs/desktops/plasma-5/kwayland-integration.nix16
-rw-r--r--pkgs/desktops/plasma-5/kwin/default.nix32
-rw-r--r--pkgs/desktops/plasma-5/kwin/follow-symlinks.patch13
-rw-r--r--pkgs/desktops/plasma-5/kwin/series2
-rw-r--r--pkgs/desktops/plasma-5/kwin/xwayland.patch13
-rw-r--r--pkgs/desktops/plasma-5/kwrited.nix9
-rw-r--r--pkgs/desktops/plasma-5/libkscreen.nix15
-rw-r--r--pkgs/desktops/plasma-5/libksysguard/0001-qdiriterator-follow-symlinks.patch25
-rw-r--r--pkgs/desktops/plasma-5/libksysguard/default.nix20
-rw-r--r--pkgs/desktops/plasma-5/milou.nix15
-rw-r--r--pkgs/desktops/plasma-5/oxygen.nix21
-rw-r--r--pkgs/desktops/plasma-5/plasma-desktop/default.nix44
-rw-r--r--pkgs/desktops/plasma-5/plasma-desktop/hwclock-path.patch24
-rw-r--r--pkgs/desktops/plasma-5/plasma-desktop/ibus.patch26
-rw-r--r--pkgs/desktops/plasma-5/plasma-desktop/qml-import-paths.patch54
-rw-r--r--pkgs/desktops/plasma-5/plasma-desktop/series4
-rw-r--r--pkgs/desktops/plasma-5/plasma-desktop/tzdir.patch18
-rw-r--r--pkgs/desktops/plasma-5/plasma-integration.nix17
-rw-r--r--pkgs/desktops/plasma-5/plasma-nm/0001-mobile-broadband-provider-info-path.patch25
-rw-r--r--pkgs/desktops/plasma-5/plasma-nm/default.nix26
-rw-r--r--pkgs/desktops/plasma-5/plasma-pa.nix17
-rw-r--r--pkgs/desktops/plasma-5/plasma-workspace-wallpapers.nix11
-rw-r--r--pkgs/desktops/plasma-5/plasma-workspace/default.nix40
-rw-r--r--pkgs/desktops/plasma-5/plasma-workspace/qml-import-path.patch91
-rw-r--r--pkgs/desktops/plasma-5/plasma-workspace/series1
-rw-r--r--pkgs/desktops/plasma-5/polkit-kde-agent.nix14
-rw-r--r--pkgs/desktops/plasma-5/powerdevil.nix15
-rw-r--r--pkgs/desktops/plasma-5/srcs.nix325
-rw-r--r--pkgs/desktops/plasma-5/startkde/default.nix54
-rwxr-xr-xpkgs/desktops/plasma-5/startkde/startkde.sh385
-rw-r--r--pkgs/desktops/plasma-5/systemsettings.nix14
56 files changed, 1869 insertions, 0 deletions
diff --git a/pkgs/desktops/plasma-5/bluedevil.nix b/pkgs/desktops/plasma-5/bluedevil.nix
new file mode 100644
index 0000000000000..1deef241a62fe
--- /dev/null
+++ b/pkgs/desktops/plasma-5/bluedevil.nix
@@ -0,0 +1,19 @@
+{
+  plasmaPackage, ecm, shared_mime_info,
+  bluez-qt, kcoreaddons, kdbusaddons, kded, ki18n, kiconthemes, kio,
+  knotifications, kwidgetsaddons, kwindowsystem, plasma-framework, qtdeclarative
+}:
+
+plasmaPackage {
+  name = "bluedevil";
+  nativeBuildInputs = [ ecm shared_mime_info ];
+  propagatedBuildInputs = [
+    bluez-qt ki18n kio kwindowsystem plasma-framework qtdeclarative kcoreaddons
+    kdbusaddons kded kiconthemes knotifications kwidgetsaddons
+  ];
+  propagatedUserEnvPkgs = [ bluez-qt.out ];
+  postInstall = ''
+    # Fix the location of logic.js for the plasmoid
+    ln -s $out/share/plasma/plasmoids/org.kde.plasma.bluetooth/contents/code/logic.js $out/share/plasma/plasmoids/org.kde.plasma.bluetooth/contents/ui/logic.js
+  '';
+}
diff --git a/pkgs/desktops/plasma-5/breeze-grub.nix b/pkgs/desktops/plasma-5/breeze-grub.nix
new file mode 100644
index 0000000000000..da0fb6f73ad78
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-grub.nix
@@ -0,0 +1,16 @@
+{
+  plasmaPackage
+}:
+
+plasmaPackage {
+  name = "breeze-grub";
+  outputs = [ "out" ];
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p "$out/grub/themes"
+    mv breeze "$out/grub/themes"
+
+    runHook postInstall
+  '';
+}
diff --git a/pkgs/desktops/plasma-5/breeze-gtk.nix b/pkgs/desktops/plasma-5/breeze-gtk.nix
new file mode 100644
index 0000000000000..57de2fa2d474a
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-gtk.nix
@@ -0,0 +1,9 @@
+{ plasmaPackage
+, ecm
+}:
+
+plasmaPackage {
+  name = "breeze-gtk";
+  nativeBuildInputs = [ ecm ];
+  cmakeFlags = [ "-DWITH_GTK3_VERSION=3.20" ];
+}
diff --git a/pkgs/desktops/plasma-5/breeze-plymouth/default.nix b/pkgs/desktops/plasma-5/breeze-plymouth/default.nix
new file mode 100644
index 0000000000000..0de1ca1f6802c
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-plymouth/default.nix
@@ -0,0 +1,16 @@
+{
+  plasmaPackage, lib, copyPathsToStore,
+  ecm,
+  plymouth
+}:
+
+plasmaPackage {
+  name = "breeze-plymouth";
+  nativeBuildInputs = [ ecm ];
+  buildInputs = [ plymouth ];
+  outputs = [ "out" ];
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  postPatch = ''
+      substituteInPlace cmake/FindPlymouth.cmake --subst-var out
+  '';
+}
diff --git a/pkgs/desktops/plasma-5/breeze-plymouth/install-paths.patch b/pkgs/desktops/plasma-5/breeze-plymouth/install-paths.patch
new file mode 100644
index 0000000000000..5d5856d122ddb
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-plymouth/install-paths.patch
@@ -0,0 +1,19 @@
+Index: breeze-plymouth-5.7.3/cmake/FindPlymouth.cmake
+===================================================================
+--- breeze-plymouth-5.7.3.orig/cmake/FindPlymouth.cmake
++++ breeze-plymouth-5.7.3/cmake/FindPlymouth.cmake
+@@ -24,12 +24,8 @@
+ include(FindPkgConfig)
+ 
+ pkg_check_modules(Plymouth ply-boot-client ply-splash-core)
+-exec_program(${PKG_CONFIG_EXECUTABLE}
+-    ARGS ply-splash-core --variable=pluginsdir
+-    OUTPUT_VARIABLE Plymouth_PLUGINSDIR)
+-exec_program(${PKG_CONFIG_EXECUTABLE}
+-    ARGS ply-splash-core --variable=themesdir
+-    OUTPUT_VARIABLE Plymouth_THEMESDIR)
++set(Plymouth_PLUGINSDIR "@out@/lib/plymouth")
++set(Plymouth_THEMESDIR "@out@/share/plymouth/themes")
+ 
+ find_package_handle_standard_args(Plymouth
+     FOUND_VAR
diff --git a/pkgs/desktops/plasma-5/breeze-plymouth/series b/pkgs/desktops/plasma-5/breeze-plymouth/series
new file mode 100644
index 0000000000000..8920e7ca51891
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-plymouth/series
@@ -0,0 +1 @@
+install-paths.patch
diff --git a/pkgs/desktops/plasma-5/breeze-qt4.nix b/pkgs/desktops/plasma-5/breeze-qt4.nix
new file mode 100644
index 0000000000000..b97554cd40441
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-qt4.nix
@@ -0,0 +1,24 @@
+{
+  stdenv, lib, src, version,
+  automoc4, cmake, perl, pkgconfig,
+  kdelibs4, qt4, xproto
+}:
+
+stdenv.mkDerivation {
+  name = "breeze-qt4-${version}";
+  meta = {
+    license = with lib.licenses; [
+      lgpl21Plus lgpl3Plus bsd2 mit gpl2Plus gpl3Plus fdl12
+    ];
+    platforms = lib.platforms.linux;
+    maintainers = with lib.maintainers; [ ttuegel ];
+    homepage = "http://www.kde.org";
+  };
+  inherit src;
+  buildInputs = [ kdelibs4 qt4 xproto ];
+  nativeBuildInputs = [ automoc4 cmake perl pkgconfig ];
+  cmakeFlags = [
+    "-DUSE_KDE4=ON"
+    "-DQT_QMAKE_EXECUTABLE=${qt4}/bin/qmake"
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/breeze-qt5.nix b/pkgs/desktops/plasma-5/breeze-qt5.nix
new file mode 100644
index 0000000000000..ea2776a13c598
--- /dev/null
+++ b/pkgs/desktops/plasma-5/breeze-qt5.nix
@@ -0,0 +1,17 @@
+{
+  plasmaPackage,
+  ecm,
+  frameworkintegration, kcmutils, kconfigwidgets, kcoreaddons, kdecoration,
+  kguiaddons, ki18n, kwayland, kwindowsystem, plasma-framework, qtx11extras
+}:
+
+plasmaPackage {
+  name = "breeze-qt5";
+  sname = "breeze";
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [
+    frameworkintegration kcmutils kconfigwidgets kcoreaddons kdecoration
+    kguiaddons ki18n kwayland kwindowsystem plasma-framework qtx11extras
+  ];
+  cmakeFlags = [ "-DUSE_Qt4=OFF" ];
+}
diff --git a/pkgs/desktops/plasma-5/default.nix b/pkgs/desktops/plasma-5/default.nix
new file mode 100644
index 0000000000000..683154273ae6b
--- /dev/null
+++ b/pkgs/desktops/plasma-5/default.nix
@@ -0,0 +1,101 @@
+/*
+
+# New packages
+
+READ THIS FIRST
+
+This module is for official packages in KDE Plasma 5. All available packages are
+listed in `./srcs.nix`, although a few are not yet packaged in Nixpkgs (see
+below).
+
+IF YOUR PACKAGE IS NOT LISTED IN `./srcs.nix`, IT DOES NOT GO HERE.
+
+Many of the packages released upstream are not yet built in Nixpkgs due to lack
+of demand. To add a Nixpkgs build for an upstream package, copy one of the
+existing packages here and modify it as necessary.
+
+# Updates
+
+1. Update the URL in `./fetch.sh`.
+2. Run `./maintainers/scripts/fetch-kde-qt.sh pkgs/desktops/plasma-5`
+   from the top of the Nixpkgs tree.
+3. Use `nox-review wip` to check that everything builds.
+4. Commit the changes and open a pull request.
+
+*/
+
+{
+  stdenv, lib, libsForQt5, makeSetupHook, symlinkJoin, fetchurl,
+  gconf,
+  debug ? false,
+}:
+
+let
+
+  mirror = "mirror://kde";
+  srcs = import ./srcs.nix { inherit fetchurl mirror; };
+
+  packages = self: with self; {
+    plasmaPackage = args:
+      let
+        inherit (args) name;
+        sname = args.sname or name;
+        inherit (srcs."${sname}") src version;
+      in libsForQt5.kdeDerivation (args // {
+        name = "${name}-${version}";
+        inherit src;
+
+        meta = {
+          license = with lib.licenses; [
+            lgpl21Plus lgpl3Plus bsd2 mit gpl2Plus gpl3Plus fdl12
+          ];
+          platforms = lib.platforms.linux;
+          maintainers = with lib.maintainers; [ ttuegel ];
+          homepage = "http://www.kde.org";
+        } // (args.meta or {});
+      });
+
+    bluedevil = callPackage ./bluedevil.nix {};
+    breeze-gtk = callPackage ./breeze-gtk.nix {};
+    breeze-qt4 = callPackage ./breeze-qt4.nix {
+      inherit (srcs.breeze) src version;
+    };
+    breeze-qt5 = callPackage ./breeze-qt5.nix {};
+    breeze-grub = callPackage ./breeze-grub.nix {};
+    breeze-plymouth = callPackage ./breeze-plymouth {};
+    kactivitymanagerd = callPackage ./kactivitymanagerd.nix {};
+    kde-cli-tools = callPackage ./kde-cli-tools.nix {};
+    kde-gtk-config = callPackage ./kde-gtk-config {};
+    kdecoration = callPackage ./kdecoration.nix {};
+    kdeplasma-addons = callPackage ./kdeplasma-addons.nix {};
+    kgamma5 = callPackage ./kgamma5.nix {};
+    khotkeys = callPackage ./khotkeys.nix {};
+    kinfocenter = callPackage ./kinfocenter.nix {};
+    kmenuedit = callPackage ./kmenuedit.nix {};
+    kscreen = callPackage ./kscreen.nix {};
+    kscreenlocker = callPackage ./kscreenlocker.nix {};
+    ksshaskpass = callPackage ./ksshaskpass.nix {};
+    ksysguard = callPackage ./ksysguard.nix {};
+    kwallet-pam = callPackage ./kwallet-pam.nix {};
+    kwayland-integration = callPackage ./kwayland-integration.nix {};
+    kwin = callPackage ./kwin {};
+    kwrited = callPackage ./kwrited.nix {};
+    libkscreen = callPackage ./libkscreen.nix {};
+    libksysguard = callPackage ./libksysguard {};
+    milou = callPackage ./milou.nix {};
+    oxygen = callPackage ./oxygen.nix {};
+    plasma-desktop = callPackage ./plasma-desktop {};
+    plasma-integration = callPackage ./plasma-integration.nix {};
+    plasma-nm = callPackage ./plasma-nm {};
+    plasma-pa = callPackage ./plasma-pa.nix {
+      inherit gconf;
+    };
+    plasma-workspace = callPackage ./plasma-workspace {};
+    plasma-workspace-wallpapers = callPackage ./plasma-workspace-wallpapers.nix {};
+    polkit-kde-agent = callPackage ./polkit-kde-agent.nix {};
+    powerdevil = callPackage ./powerdevil.nix {};
+    startkde = callPackage ./startkde {};
+    systemsettings = callPackage ./systemsettings.nix {};
+  };
+
+in lib.makeScope libsForQt5.newScope packages
diff --git a/pkgs/desktops/plasma-5/fetch.sh b/pkgs/desktops/plasma-5/fetch.sh
new file mode 100644
index 0000000000000..76f05bad0a778
--- /dev/null
+++ b/pkgs/desktops/plasma-5/fetch.sh
@@ -0,0 +1 @@
+WGET_ARGS=( http://download.kde.org/stable/plasma/5.8.5/ -A '*.tar.xz' )
diff --git a/pkgs/desktops/plasma-5/kactivitymanagerd.nix b/pkgs/desktops/plasma-5/kactivitymanagerd.nix
new file mode 100644
index 0000000000000..bb90fd6d3ab05
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kactivitymanagerd.nix
@@ -0,0 +1,14 @@
+{ plasmaPackage
+, ecm
+, boost, kconfig, kcoreaddons, kdbusaddons, ki18n, kio, kglobalaccel
+, kwindowsystem, kxmlgui
+}:
+
+plasmaPackage {
+  name = "kactivitymanagerd";
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [
+    boost kconfig kcoreaddons kdbusaddons kglobalaccel ki18n kio kwindowsystem
+    kxmlgui
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kde-cli-tools.nix b/pkgs/desktops/plasma-5/kde-cli-tools.nix
new file mode 100644
index 0000000000000..33a7340cb85f0
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kde-cli-tools.nix
@@ -0,0 +1,14 @@
+{
+  plasmaPackage, ecm,
+  kcmutils, kconfig, kdelibs4support, kdesu, kdoctools, ki18n, kiconthemes,
+  kwindowsystem, qtsvg, qtx11extras
+}:
+
+plasmaPackage {
+  name = "kde-cli-tools";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [
+    kcmutils kconfig kdesu kdelibs4support ki18n kiconthemes kwindowsystem qtsvg
+    qtx11extras
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kde-gtk-config/0001-follow-symlinks.patch b/pkgs/desktops/plasma-5/kde-gtk-config/0001-follow-symlinks.patch
new file mode 100644
index 0000000000000..d610d19eedd22
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kde-gtk-config/0001-follow-symlinks.patch
@@ -0,0 +1,52 @@
+From 33b25c2e3c7a002c7f726cd79fc4bab22b1299be Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Tue, 27 Oct 2015 18:07:54 -0500
+Subject: [PATCH] follow symlinks
+
+---
+ src/appearancegtk2.cpp  | 2 +-
+ src/iconthemesmodel.cpp | 2 +-
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+
+diff --git a/src/appearancegtk2.cpp b/src/appearancegtk2.cpp
+index b1e0b52..095cddc 100644
+--- a/src/appearancegtk2.cpp
++++ b/src/appearancegtk2.cpp
+@@ -73,7 +73,7 @@ QString AppearanceGTK2::themesGtkrcFile(const QString& themeName) const
+     QStringList themes=installedThemes();
+     themes=themes.filter(QRegExp("/"+themeName+"/?$"));
+     if(themes.size()==1) {
+-        QDirIterator it(themes.first(), QDirIterator::Subdirectories);
++        QDirIterator it(themes.first(), QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+         while(it.hasNext()) {
+             it.next();
+             if(it.fileName()=="gtkrc") {
+diff --git a/src/iconthemesmodel.cpp b/src/iconthemesmodel.cpp
+index 07c7ad7..b04d978 100644
+--- a/src/iconthemesmodel.cpp
++++ b/src/iconthemesmodel.cpp
+@@ -46,7 +46,7 @@ QList<QDir> IconThemesModel::installedThemesPaths()
+     
+     foreach(const QString& dir, dirs) {
+         QDir userIconsDir(dir);
+-        QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs|QDir::NoSymLinks);
++        QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs);
+         while(it.hasNext()) {
+             QString currentPath = it.next();
+             QDir dir(currentPath);
+-- 
+2.6.2
+
+diff --git a/src/cursorthemesmodel.cpp b/src/cursorthemesmodel.cpp
+index 926a666..85b10f8 100644
+--- a/src/cursorthemesmodel.cpp
++++ b/src/cursorthemesmodel.cpp
+@@ -47,7 +47,7 @@ QList<QDir> CursorThemesModel::installedThemesPaths()
+ 
+     foreach(const QString& dir, dirs) {
+         QDir userIconsDir(dir);
+-        QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs|QDir::NoSymLinks);
++        QDirIterator it(userIconsDir.path(), QDir::NoDotAndDotDot|QDir::AllDirs);
+         while(it.hasNext()) {
+             QString currentPath = it.next();
+             QDir dir(currentPath);
diff --git a/pkgs/desktops/plasma-5/kde-gtk-config/default.nix b/pkgs/desktops/plasma-5/kde-gtk-config/default.nix
new file mode 100644
index 0000000000000..10e55f0d69804
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kde-gtk-config/default.nix
@@ -0,0 +1,27 @@
+{ plasmaPackage
+, ecm
+, glib
+, gtk2
+, gtk3
+, karchive
+, kcmutils
+, kconfigwidgets
+, ki18n
+, kiconthemes
+, kio
+, knewstuff
+}:
+
+plasmaPackage {
+  name = "kde-gtk-config";
+  patches = [ ./0001-follow-symlinks.patch ];
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [
+    ki18n kio glib gtk2 gtk3 karchive kcmutils kconfigwidgets kiconthemes
+    knewstuff
+  ];
+  cmakeFlags = [
+    "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
+    "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include"
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kdecoration.nix b/pkgs/desktops/plasma-5/kdecoration.nix
new file mode 100644
index 0000000000000..a0f9d93e60b01
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kdecoration.nix
@@ -0,0 +1,6 @@
+{ plasmaPackage, ecm }:
+
+plasmaPackage {
+  name = "kdecoration";
+  nativeBuildInputs = [ ecm ];
+}
diff --git a/pkgs/desktops/plasma-5/kdeplasma-addons.nix b/pkgs/desktops/plasma-5/kdeplasma-addons.nix
new file mode 100644
index 0000000000000..a2805f5d804b2
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kdeplasma-addons.nix
@@ -0,0 +1,20 @@
+{ plasmaPackage, ecm, kdoctools
+, kconfig, kconfigwidgets, kcoreaddons, kcmutils, kdelibs4support, ki18n
+, kio, knewstuff, kross, krunner, kservice, ksysguard, kunitconversion
+, plasma-framework, plasma-workspace, qtdeclarative, qtx11extras
+, ibus
+}:
+
+plasmaPackage {
+  name = "kdeplasma-addons";
+  nativeBuildInputs = [
+    ecm
+    kdoctools
+  ];
+  propagatedBuildInputs = [
+    kconfig kconfigwidgets kcoreaddons kcmutils kdelibs4support kio knewstuff
+    kross krunner kservice ksysguard kunitconversion plasma-framework
+    plasma-workspace qtdeclarative qtx11extras
+    ibus
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kgamma5.nix b/pkgs/desktops/plasma-5/kgamma5.nix
new file mode 100644
index 0000000000000..70d7cc17a1cae
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kgamma5.nix
@@ -0,0 +1,9 @@
+{ plasmaPackage, ecm, kdoctools, kdelibs4support
+, qtx11extras
+}:
+
+plasmaPackage {
+  name = "kgamma5";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [ kdelibs4support qtx11extras ];
+}
diff --git a/pkgs/desktops/plasma-5/khotkeys.nix b/pkgs/desktops/plasma-5/khotkeys.nix
new file mode 100644
index 0000000000000..f23a17e5479e9
--- /dev/null
+++ b/pkgs/desktops/plasma-5/khotkeys.nix
@@ -0,0 +1,22 @@
+{ plasmaPackage, ecm, kdoctools, kcmutils
+, kdbusaddons, kdelibs4support, kglobalaccel, ki18n, kio, kxmlgui
+, plasma-framework, plasma-workspace, qtx11extras
+, fetchpatch
+}:
+
+plasmaPackage {
+  name = "khotkeys";
+  nativeBuildInputs = [ ecm kdoctools ];
+
+  patches = [
+    # Patch is in 5.9 and up.
+    (fetchpatch {
+      url = "https://cgit.kde.org/khotkeys.git/patch/?id=f8f7eaaf41e2b95ebfa4b2e35c6ee252524a471b";
+      sha256 = "1wxx3qv16jd623jh728xcda8i4y1daq25skwilhv4cfvqxyzk7nn";
+    })
+  ];
+  propagatedBuildInputs = [
+    kdelibs4support kglobalaccel ki18n kio plasma-framework plasma-workspace
+    qtx11extras kcmutils kdbusaddons kxmlgui
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kinfocenter.nix b/pkgs/desktops/plasma-5/kinfocenter.nix
new file mode 100644
index 0000000000000..939e4fa62a9c2
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kinfocenter.nix
@@ -0,0 +1,17 @@
+{
+  plasmaPackage,
+  ecm, kdoctools,
+  kcmutils, kcompletion, kconfig, kconfigwidgets, kcoreaddons, kdbusaddons,
+  kdeclarative, kdelibs4support, ki18n, kiconthemes, kio, kpackage, kservice,
+  kwayland, kwidgetsaddons, kxmlgui, libraw1394, mesa_glu, pciutils, solid
+}:
+
+plasmaPackage {
+  name = "kinfocenter";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [
+    kcmutils kcompletion kconfig kconfigwidgets kcoreaddons kdbusaddons
+    kdeclarative kdelibs4support ki18n kiconthemes kio kpackage kservice
+    kwayland kwidgetsaddons kxmlgui libraw1394 mesa_glu pciutils solid
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kmenuedit.nix b/pkgs/desktops/plasma-5/kmenuedit.nix
new file mode 100644
index 0000000000000..f10bf6bb3cdda
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kmenuedit.nix
@@ -0,0 +1,14 @@
+{
+  plasmaPackage,
+  ecm, kdoctools,
+  kdbusaddons, kdelibs4support, khotkeys, ki18n, kiconthemes, kio, kxmlgui,
+  sonnet
+}:
+
+plasmaPackage {
+  name = "kmenuedit";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [
+    kdbusaddons kdelibs4support khotkeys ki18n kiconthemes kio kxmlgui sonnet
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kscreen.nix b/pkgs/desktops/plasma-5/kscreen.nix
new file mode 100644
index 0000000000000..ecbd88c2146dc
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kscreen.nix
@@ -0,0 +1,13 @@
+{ plasmaPackage, ecm, kconfig, kconfigwidgets
+, kdbusaddons, kglobalaccel, ki18n, kwidgetsaddons, kxmlgui
+, libkscreen, qtdeclarative, qtgraphicaleffects
+}:
+
+plasmaPackage {
+  name = "kscreen";
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [
+    kglobalaccel ki18n libkscreen qtdeclarative qtgraphicaleffects kconfig
+    kconfigwidgets kdbusaddons kwidgetsaddons kxmlgui
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kscreenlocker.nix b/pkgs/desktops/plasma-5/kscreenlocker.nix
new file mode 100644
index 0000000000000..3c5d7b374724a
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kscreenlocker.nix
@@ -0,0 +1,15 @@
+{
+  plasmaPackage,
+  ecm, kdoctools,
+  kcmutils, kcrash, kdeclarative, kdelibs4support, kglobalaccel, kidletime,
+  kwayland, libXcursor, pam, plasma-framework, qtdeclarative, wayland
+}:
+
+plasmaPackage {
+  name = "kscreenlocker";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [
+    kcmutils kcrash kdeclarative kdelibs4support kglobalaccel kidletime kwayland
+    libXcursor pam plasma-framework qtdeclarative wayland
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/ksshaskpass.nix b/pkgs/desktops/plasma-5/ksshaskpass.nix
new file mode 100644
index 0000000000000..80b529a666854
--- /dev/null
+++ b/pkgs/desktops/plasma-5/ksshaskpass.nix
@@ -0,0 +1,9 @@
+{ plasmaPackage, ecm, kdoctools, kcoreaddons
+, ki18n, kwallet, kwidgetsaddons
+}:
+
+plasmaPackage {
+  name = "ksshaskpass";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [ kcoreaddons ki18n kwallet kwidgetsaddons ];
+}
diff --git a/pkgs/desktops/plasma-5/ksysguard.nix b/pkgs/desktops/plasma-5/ksysguard.nix
new file mode 100644
index 0000000000000..f7e5cced708a7
--- /dev/null
+++ b/pkgs/desktops/plasma-5/ksysguard.nix
@@ -0,0 +1,17 @@
+{
+  plasmaPackage,
+  ecm, kdoctools,
+  lm_sensors,
+  kconfig, kcoreaddons, kdelibs4support, ki18n, kiconthemes, kitemviews,
+  knewstuff, libksysguard, qtwebkit
+}:
+
+plasmaPackage {
+  name = "ksysguard";
+  nativeBuildInputs = [ ecm kdoctools ];
+  buildInputs = [ lm_sensors ];
+  propagatedBuildInputs = [
+    kconfig kcoreaddons kitemviews knewstuff kiconthemes libksysguard
+    kdelibs4support ki18n qtwebkit
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kwallet-pam.nix b/pkgs/desktops/plasma-5/kwallet-pam.nix
new file mode 100644
index 0000000000000..86ba52292f9eb
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwallet-pam.nix
@@ -0,0 +1,11 @@
+{ plasmaPackage, ecm, pam, socat, libgcrypt
+}:
+
+plasmaPackage {
+  name = "kwallet-pam";
+
+  nativeBuildInputs = [ ecm ];
+
+  buildInputs = [ pam socat libgcrypt ];
+
+}
diff --git a/pkgs/desktops/plasma-5/kwayland-integration.nix b/pkgs/desktops/plasma-5/kwayland-integration.nix
new file mode 100644
index 0000000000000..376e8ed7cbda4
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwayland-integration.nix
@@ -0,0 +1,16 @@
+{ plasmaPackage
+, ecm
+, kidletime
+, kwayland
+, kwindowsystem
+}:
+
+plasmaPackage {
+  name = "kwayland-integration";
+  nativeBuildInputs = [
+    ecm
+  ];
+  propagatedBuildInputs = [
+    kidletime kwindowsystem kwayland
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/kwin/default.nix b/pkgs/desktops/plasma-5/kwin/default.nix
new file mode 100644
index 0000000000000..73e40cdb114c0
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwin/default.nix
@@ -0,0 +1,32 @@
+{
+  plasmaPackage, lib, copyPathsToStore,
+  ecm, kdoctools,
+  breeze-qt5, epoxy, kactivities, kcompletion, kcmutils, kconfig,
+  kconfigwidgets, kcoreaddons, kcrash, kdeclarative, kdecoration, kglobalaccel,
+  ki18n, kiconthemes, kidletime, kinit, kio, knewstuff, knotifications,
+  kpackage, kscreenlocker, kservice, kwayland, kwidgetsaddons, kwindowsystem,
+  kxmlgui, libinput, libICE, libSM, plasma-framework, qtdeclarative,
+  qtmultimedia, qtscript, qtx11extras, udev, wayland, xcb-util-cursor, xwayland
+}:
+
+plasmaPackage {
+  name = "kwin";
+  nativeBuildInputs = [
+    ecm
+    kdoctools
+  ];
+  propagatedBuildInputs = [
+    breeze-qt5 epoxy kactivities kcmutils kcompletion kconfig kconfigwidgets
+    kcoreaddons kcrash kdeclarative kdecoration kglobalaccel ki18n kiconthemes
+    kidletime kinit kio knewstuff knotifications kpackage kscreenlocker kservice
+    kwayland kwidgetsaddons kwindowsystem kxmlgui libinput libICE libSM
+    plasma-framework qtdeclarative qtmultimedia qtscript qtx11extras udev
+    wayland xcb-util-cursor xwayland
+  ];
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  postPatch = ''
+    substituteInPlace main_wayland.cpp \
+        --subst-var-by xwayland ${lib.getBin xwayland}/bin/Xwayland
+  '';
+  cmakeFlags = [ "-DCMAKE_SKIP_BUILD_RPATH=OFF" ];
+}
diff --git a/pkgs/desktops/plasma-5/kwin/follow-symlinks.patch b/pkgs/desktops/plasma-5/kwin/follow-symlinks.patch
new file mode 100644
index 0000000000000..60b8f5ef541f3
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwin/follow-symlinks.patch
@@ -0,0 +1,13 @@
+Index: kwin-5.7.3/plugins/kdecorations/aurorae/src/aurorae.cpp
+===================================================================
+--- kwin-5.7.3.orig/plugins/kdecorations/aurorae/src/aurorae.cpp
++++ kwin-5.7.3/plugins/kdecorations/aurorae/src/aurorae.cpp
+@@ -211,7 +211,7 @@ void Helper::init()
+     // so let's try to locate our plugin:
+     QString pluginPath;
+     for (const QString &path : m_engine->importPathList()) {
+-        QDirIterator it(path, QDirIterator::Subdirectories);
++        QDirIterator it(path, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+         while (it.hasNext()) {
+             it.next();
+             QFileInfo fileInfo = it.fileInfo();
diff --git a/pkgs/desktops/plasma-5/kwin/series b/pkgs/desktops/plasma-5/kwin/series
new file mode 100644
index 0000000000000..9dbc88f499752
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwin/series
@@ -0,0 +1,2 @@
+follow-symlinks.patch
+xwayland.patch
diff --git a/pkgs/desktops/plasma-5/kwin/xwayland.patch b/pkgs/desktops/plasma-5/kwin/xwayland.patch
new file mode 100644
index 0000000000000..5fde01d08bf32
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwin/xwayland.patch
@@ -0,0 +1,13 @@
+Index: kwin-5.7.3/main_wayland.cpp
+===================================================================
+--- kwin-5.7.3.orig/main_wayland.cpp
++++ kwin-5.7.3/main_wayland.cpp
+@@ -315,7 +315,7 @@ void ApplicationWayland::startXwaylandSe
+ 
+     m_xwaylandProcess = new Process(kwinApp());
+     m_xwaylandProcess->setProcessChannelMode(QProcess::ForwardedErrorChannel);
+-    m_xwaylandProcess->setProgram(QStringLiteral("Xwayland"));
++    m_xwaylandProcess->setProgram(QStringLiteral("@xwayland@"));
+     QProcessEnvironment env = m_environment;
+     env.insert("WAYLAND_SOCKET", QByteArray::number(wlfd));
+     m_xwaylandProcess->setProcessEnvironment(env);
diff --git a/pkgs/desktops/plasma-5/kwrited.nix b/pkgs/desktops/plasma-5/kwrited.nix
new file mode 100644
index 0000000000000..8dd814f783d09
--- /dev/null
+++ b/pkgs/desktops/plasma-5/kwrited.nix
@@ -0,0 +1,9 @@
+{ plasmaPackage, ecm, kcoreaddons, ki18n, kpty
+, knotifications, kdbusaddons
+}:
+
+plasmaPackage {
+  name = "kwrited";
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [ kcoreaddons ki18n kpty knotifications kdbusaddons ];
+}
diff --git a/pkgs/desktops/plasma-5/libkscreen.nix b/pkgs/desktops/plasma-5/libkscreen.nix
new file mode 100644
index 0000000000000..838ab6ef0e5c3
--- /dev/null
+++ b/pkgs/desktops/plasma-5/libkscreen.nix
@@ -0,0 +1,15 @@
+{ plasmaPackage
+, ecm
+, kwayland, libXrandr
+, qtx11extras
+}:
+
+plasmaPackage {
+  name = "libkscreen";
+  nativeBuildInputs = [
+    ecm
+  ];
+  propagatedBuildInputs = [
+    kwayland libXrandr qtx11extras
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/libksysguard/0001-qdiriterator-follow-symlinks.patch b/pkgs/desktops/plasma-5/libksysguard/0001-qdiriterator-follow-symlinks.patch
new file mode 100644
index 0000000000000..fbbb11ae7556b
--- /dev/null
+++ b/pkgs/desktops/plasma-5/libksysguard/0001-qdiriterator-follow-symlinks.patch
@@ -0,0 +1,25 @@
+From 46164a50de4102d02ae9d1d480acdd4b12303db8 Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Wed, 14 Oct 2015 07:07:22 -0500
+Subject: [PATCH] qdiriterator follow symlinks
+
+---
+ processui/scripting.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/processui/scripting.cpp b/processui/scripting.cpp
+index efed8ff..841761a 100644
+--- a/processui/scripting.cpp
++++ b/processui/scripting.cpp
+@@ -167,7 +167,7 @@ void Scripting::loadContextMenu() {
+     QStringList scripts;
+     const QStringList dirs = QStandardPaths::locateAll(QStandardPaths::GenericDataLocation, "ksysguard/scripts/", QStandardPaths::LocateDirectory);
+     Q_FOREACH (const QString& dir, dirs) {
+-        QDirIterator it(dir, QStringList() << QStringLiteral("*.desktop"), QDir::NoFilter, QDirIterator::Subdirectories);
++        QDirIterator it(dir, QStringList() << QStringLiteral("*.desktop"), QDir::NoFilter, QDirIterator::Subdirectories | QDirIterator::FollowSymlinks);
+         while (it.hasNext()) {
+             scripts.append(it.next());
+         }
+-- 
+2.5.2
+
diff --git a/pkgs/desktops/plasma-5/libksysguard/default.nix b/pkgs/desktops/plasma-5/libksysguard/default.nix
new file mode 100644
index 0000000000000..2d81d061f4c77
--- /dev/null
+++ b/pkgs/desktops/plasma-5/libksysguard/default.nix
@@ -0,0 +1,20 @@
+{
+  plasmaPackage,
+  ecm,
+  kauth, kcompletion, kconfig, kconfigwidgets, kcoreaddons, ki18n, kiconthemes,
+  kservice, kwidgetsaddons, kwindowsystem, plasma-framework, qtscript, qtwebkit,
+  qtx11extras
+}:
+
+plasmaPackage {
+  name = "libksysguard";
+  patches = [
+    ./0001-qdiriterator-follow-symlinks.patch
+  ];
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [
+    kauth kconfig ki18n kiconthemes kwindowsystem kcompletion kconfigwidgets
+    kcoreaddons kservice kwidgetsaddons plasma-framework qtscript qtx11extras
+    qtwebkit
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/milou.nix b/pkgs/desktops/plasma-5/milou.nix
new file mode 100644
index 0000000000000..dbf9d0b9e5378
--- /dev/null
+++ b/pkgs/desktops/plasma-5/milou.nix
@@ -0,0 +1,15 @@
+{ plasmaPackage, ecm, qtscript, qtdeclarative
+, kcoreaddons, ki18n, kdeclarative, kservice, plasma-framework
+, krunner
+}:
+
+plasmaPackage {
+  name = "milou";
+  nativeBuildInputs = [
+    ecm
+  ];
+  propagatedBuildInputs = [
+    kdeclarative ki18n krunner plasma-framework qtdeclarative qtscript
+    kcoreaddons kservice
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/oxygen.nix b/pkgs/desktops/plasma-5/oxygen.nix
new file mode 100644
index 0000000000000..ca63c8d7a3771
--- /dev/null
+++ b/pkgs/desktops/plasma-5/oxygen.nix
@@ -0,0 +1,21 @@
+{
+  plasmaPackage, kdeWrapper,
+  ecm,
+  frameworkintegration, kcmutils, kcompletion, kconfig, kdecoration, kguiaddons,
+  ki18n, kwidgetsaddons, kservice, kwayland, kwindowsystem, qtx11extras
+}:
+
+let
+  unwrapped = plasmaPackage {
+    name = "oxygen";
+    nativeBuildInputs = [ ecm ];
+    propagatedBuildInputs = [
+      frameworkintegration kcmutils kcompletion kconfig kdecoration kguiaddons
+      ki18n kservice kwayland kwidgetsaddons kwindowsystem qtx11extras
+    ];
+  };
+in
+kdeWrapper {
+  inherit unwrapped;
+  targets = [ "bin/oxygen-demo5" "bin/oxygen-settings5" ];
+}
diff --git a/pkgs/desktops/plasma-5/plasma-desktop/default.nix b/pkgs/desktops/plasma-5/plasma-desktop/default.nix
new file mode 100644
index 0000000000000..21ceec25d53f5
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-desktop/default.nix
@@ -0,0 +1,44 @@
+{
+  plasmaPackage, lib, copyPathsToStore,
+  ecm, kdoctools,
+  attica, baloo, boost, fontconfig, ibus, kactivities, kactivities-stats, kauth,
+  kcmutils, kdbusaddons, kdeclarative, kded, kdelibs4support, kemoticons,
+  kglobalaccel, ki18n, kitemmodels, knewstuff, knotifications, knotifyconfig,
+  kpeople, krunner, ksysguard, kwallet, kwin, libXcursor, libXft,
+  libcanberra_kde, libpulseaudio, libxkbfile, phonon, plasma-framework,
+  plasma-workspace, qtdeclarative, qtquickcontrols, qtsvg, qtx11extras,
+  xf86inputevdev, xf86inputsynaptics, xinput, xkeyboard_config, xorgserver,
+  utillinux
+}:
+
+plasmaPackage rec {
+  name = "plasma-desktop";
+  nativeBuildInputs = [ ecm kdoctools ];
+  buildInputs = [
+    attica boost fontconfig ibus kcmutils kdbusaddons kded kitemmodels knewstuff
+    knotifications knotifyconfig kwallet libcanberra_kde libXcursor
+    libpulseaudio libXft libxkbfile phonon qtsvg xf86inputevdev
+    xf86inputsynaptics xkeyboard_config xinput baloo kactivities
+    kactivities-stats kauth kdeclarative kdelibs4support kemoticons kglobalaccel
+    ki18n kpeople krunner kwin plasma-framework plasma-workspace qtdeclarative
+    qtquickcontrols qtx11extras ksysguard
+  ];
+
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+  postPatch = ''
+    substituteInPlace kcms/dateandtime/helper.cpp \
+        --subst-var hwclock "${utillinux}/sbin/hwclock"
+
+    sed '1i#include <cmath>' -i kcms/touchpad/src/backends/x11/synapticstouchpad.cpp
+  '';
+  NIX_CFLAGS_COMPILE = [ "-I${xorgserver.dev}/include/xorg" ];
+  cmakeFlags = [
+    "-DEvdev_INCLUDE_DIRS=${xf86inputevdev.dev}/include/xorg"
+    "-DSynaptics_INCLUDE_DIRS=${xf86inputsynaptics.dev}/include/xorg"
+  ];
+  postInstall = ''
+    # Display ~/Desktop contents on the desktop by default.
+    sed -i "$out/share/plasma/shells/org.kde.plasma.desktop/contents/defaults" \
+        -e 's/Containment=org.kde.desktopcontainment/Containment=org.kde.plasma.folder/'
+  '';
+}
diff --git a/pkgs/desktops/plasma-5/plasma-desktop/hwclock-path.patch b/pkgs/desktops/plasma-5/plasma-desktop/hwclock-path.patch
new file mode 100644
index 0000000000000..5623de84668f8
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-desktop/hwclock-path.patch
@@ -0,0 +1,24 @@
+Index: plasma-desktop-5.8.5/kcms/dateandtime/helper.cpp
+===================================================================
+--- plasma-desktop-5.8.5.orig/kcms/dateandtime/helper.cpp
++++ plasma-desktop-5.8.5/kcms/dateandtime/helper.cpp
+@@ -48,10 +48,6 @@
+ #include <sys/stat.h>
+ #endif
+ 
+-// We cannot rely on the $PATH environment variable, because D-Bus activation
+-// clears it. So we have to use a reasonable default.
+-static const QString exePath = QStringLiteral("/usr/sbin:/usr/bin:/sbin:/bin");
+-
+ int ClockHelper::ntp( const QStringList& ntpServers, bool ntpEnabled )
+ {
+     int ret = 0;
+@@ -227,7 +223,7 @@ int ClockHelper::tzreset()
+ 
+ void ClockHelper::toHwclock()
+ {
+-    QString hwclock = KStandardDirs::findExe(QStringLiteral("hwclock"), exePath);
++    QString hwclock = "@hwclock@";
+     if (!hwclock.isEmpty()) {
+         KProcess::execute(hwclock, QStringList() << QStringLiteral("--systohc"));
+     }
diff --git a/pkgs/desktops/plasma-5/plasma-desktop/ibus.patch b/pkgs/desktops/plasma-5/plasma-desktop/ibus.patch
new file mode 100644
index 0000000000000..d5ac4b2508758
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-desktop/ibus.patch
@@ -0,0 +1,26 @@
+Index: plasma-desktop-5.8.5/kcms/keyboard/xkb_helper.cpp
+===================================================================
+--- plasma-desktop-5.8.5.orig/kcms/keyboard/xkb_helper.cpp
++++ plasma-desktop-5.8.5/kcms/keyboard/xkb_helper.cpp
+@@ -185,21 +185,5 @@ bool XkbHelper::initializeKeyboardLayout
+ 
+ bool XkbHelper::preInitialize()
+ {
+-    // stop ibus so it does not mess with our layouts, we can remove this when we integrate IM into keyboard module
+-
+-    QString ibusExe = QStandardPaths::findExecutable(QStringLiteral("ibus"));
+-    if( ibusExe.isEmpty() ) {
+-        return 0;
+-    }
+-
+-    KProcess ibusProcess;
+-    ibusProcess << ibusExe << QStringLiteral("exit");
+-    ibusProcess.setOutputChannelMode(KProcess::SeparateChannels);
+-    int res = ibusProcess.execute();
+-
+-    if( res == 0 ) {
+-        qCWarning(KCM_KEYBOARD) << "ibus successfully stopped";
+-    }
+-
+     return 0;
+ }
diff --git a/pkgs/desktops/plasma-5/plasma-desktop/qml-import-paths.patch b/pkgs/desktops/plasma-5/plasma-desktop/qml-import-paths.patch
new file mode 100644
index 0000000000000..def5b577b972a
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-desktop/qml-import-paths.patch
@@ -0,0 +1,54 @@
+Index: plasma-desktop-5.8.5/applets/pager/package/contents/ui/main.qml
+===================================================================
+--- plasma-desktop-5.8.5.orig/applets/pager/package/contents/ui/main.qml
++++ plasma-desktop-5.8.5/applets/pager/package/contents/ui/main.qml
+@@ -25,7 +25,7 @@ import org.kde.plasma.components 2.0 as
+ import org.kde.kquickcontrolsaddons 2.0 as KQuickControlsAddonsComponents
+ import org.kde.draganddrop 2.0
+ import org.kde.plasma.private.pager 2.0
+-import "utils.js" as Utils
++import "../code/utils.js" as Utils
+ 
+ MouseArea {
+     id: root
+Index: plasma-desktop-5.8.5/containments/desktop/package/contents/ui/FolderView.qml
+===================================================================
+--- plasma-desktop-5.8.5.orig/containments/desktop/package/contents/ui/FolderView.qml
++++ plasma-desktop-5.8.5/containments/desktop/package/contents/ui/FolderView.qml
+@@ -27,7 +27,7 @@ import org.kde.plasma.extras 2.0 as Plas
+ import org.kde.kquickcontrolsaddons 2.0
+ 
+ import org.kde.private.desktopcontainment.folder 0.1 as Folder
+-import "FolderTools.js" as FolderTools
++import "../code/FolderTools.js" as FolderTools
+ 
+ Item {
+     id: main
+Index: plasma-desktop-5.8.5/containments/desktop/package/contents/ui/main.qml
+===================================================================
+--- plasma-desktop-5.8.5.orig/containments/desktop/package/contents/ui/main.qml
++++ plasma-desktop-5.8.5/containments/desktop/package/contents/ui/main.qml
+@@ -30,8 +30,8 @@ import org.kde.kquickcontrolsaddons 2.0
+ 
+ import org.kde.private.desktopcontainment.desktop 0.1 as Desktop
+ 
+-import "LayoutManager.js" as LayoutManager
+-import "FolderTools.js" as FolderTools
++import "../code/LayoutManager.js" as LayoutManager
++import "../code/FolderTools.js" as FolderTools
+ 
+ DragDrop.DropArea {
+     id: root
+Index: plasma-desktop-5.8.5/containments/panel/contents/ui/main.qml
+===================================================================
+--- plasma-desktop-5.8.5.orig/containments/panel/contents/ui/main.qml
++++ plasma-desktop-5.8.5/containments/panel/contents/ui/main.qml
+@@ -25,7 +25,7 @@ import org.kde.plasma.components 2.0 as
+ import org.kde.kquickcontrolsaddons 2.0
+ import org.kde.draganddrop 2.0 as DragDrop
+ 
+-import "LayoutManager.js" as LayoutManager
++import "../code/LayoutManager.js" as LayoutManager
+ 
+ DragDrop.DropArea {
+     id: root
diff --git a/pkgs/desktops/plasma-5/plasma-desktop/series b/pkgs/desktops/plasma-5/plasma-desktop/series
new file mode 100644
index 0000000000000..36778cd1c5608
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-desktop/series
@@ -0,0 +1,4 @@
+qml-import-paths.patch
+hwclock-path.patch
+tzdir.patch
+ibus.patch
diff --git a/pkgs/desktops/plasma-5/plasma-desktop/tzdir.patch b/pkgs/desktops/plasma-5/plasma-desktop/tzdir.patch
new file mode 100644
index 0000000000000..97504b330fed4
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-desktop/tzdir.patch
@@ -0,0 +1,18 @@
+Index: plasma-desktop-5.8.5/kcms/dateandtime/helper.cpp
+===================================================================
+--- plasma-desktop-5.8.5.orig/kcms/dateandtime/helper.cpp
++++ plasma-desktop-5.8.5/kcms/dateandtime/helper.cpp
+@@ -181,7 +181,12 @@ int ClockHelper::tz( const QString& sele
+ 
+     val = selectedzone;
+ #else
+-    QString tz = "/usr/share/zoneinfo/" + selectedzone;
++    QString tzdir = QString::fromLocal8Bit(qgetenv("TZDIR"));
++    QString tz = tzdir + "/" + selectedzone;
++    if (tzdir.isEmpty()) {
++      // Standard Linux path
++      tz = "/usr/share/zoneinfo/" + selectedzone;
++    }
+ 
+     if (QFile::exists(tz)) { // make sure the new TZ really exists
+         QFile::remove(QStringLiteral("/etc/localtime"));
diff --git a/pkgs/desktops/plasma-5/plasma-integration.nix b/pkgs/desktops/plasma-5/plasma-integration.nix
new file mode 100644
index 0000000000000..e8680fea930a0
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-integration.nix
@@ -0,0 +1,17 @@
+{ plasmaPackage, ecm
+, breeze-qt5, kconfig, kconfigwidgets, kiconthemes, kio, kwayland
+, libXcursor
+}:
+
+# TODO: install Noto Sans and Oxygen Mono fonts with plasma-integration
+
+plasmaPackage {
+  name = "plasma-integration";
+  nativeBuildInputs = [
+    ecm
+  ];
+  buildInputs = [
+    breeze-qt5 kconfig kconfigwidgets kiconthemes kio kwayland
+    libXcursor
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/plasma-nm/0001-mobile-broadband-provider-info-path.patch b/pkgs/desktops/plasma-5/plasma-nm/0001-mobile-broadband-provider-info-path.patch
new file mode 100644
index 0000000000000..79b5cfb437e26
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-nm/0001-mobile-broadband-provider-info-path.patch
@@ -0,0 +1,25 @@
+From faf13c97ff1192a201843b9d52f4002dbd9022af Mon Sep 17 00:00:00 2001
+From: Thomas Tuegel <ttuegel@gmail.com>
+Date: Sun, 25 Oct 2015 09:09:27 -0500
+Subject: [PATCH] mobile-broadband-provider-info path
+
+---
+ libs/editor/mobileproviders.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/libs/editor/mobileproviders.cpp b/libs/editor/mobileproviders.cpp
+index 568cb34..98a5992 100644
+--- a/libs/editor/mobileproviders.cpp
++++ b/libs/editor/mobileproviders.cpp
+@@ -26,7 +26,7 @@
+ 
+ #include <KLocale>
+ 
+-const QString MobileProviders::ProvidersFile = "/usr/share/mobile-broadband-provider-info/serviceproviders.xml";
++const QString MobileProviders::ProvidersFile = "@mobile_broadband_provider_info@/share/mobile-broadband-provider-info/serviceproviders.xml";
+ 
+ bool localeAwareCompare(const QString & one, const QString & two) {
+     return one.localeAwareCompare(two) < 0;
+-- 
+2.6.2
+
diff --git a/pkgs/desktops/plasma-5/plasma-nm/default.nix b/pkgs/desktops/plasma-5/plasma-nm/default.nix
new file mode 100644
index 0000000000000..b6d18dbf91d98
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-nm/default.nix
@@ -0,0 +1,26 @@
+{ plasmaPackage, substituteAll, ecm, kdoctools
+, kcompletion, kconfigwidgets, kcoreaddons, kdbusaddons, kdeclarative
+, kdelibs4support, ki18n, kiconthemes, kinit, kio, kitemviews
+, knotifications, kservice, kwallet, kwidgetsaddons, kwindowsystem
+, kxmlgui, mobile_broadband_provider_info
+, modemmanager-qt, networkmanager-qt, openconnect, plasma-framework
+, qca-qt5, qtdeclarative, solid
+}:
+
+plasmaPackage {
+  name = "plasma-nm";
+  patches = [
+    (substituteAll {
+      src = ./0001-mobile-broadband-provider-info-path.patch;
+      inherit mobile_broadband_provider_info;
+    })
+  ];
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [
+    kdeclarative kdelibs4support ki18n kio kwindowsystem plasma-framework
+    qtdeclarative kcompletion kconfigwidgets kcoreaddons kdbusaddons kiconthemes
+    kinit kitemviews knotifications kservice kwallet kwidgetsaddons kxmlgui
+    mobile_broadband_provider_info modemmanager-qt networkmanager-qt openconnect
+    qca-qt5 solid
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/plasma-pa.nix b/pkgs/desktops/plasma-5/plasma-pa.nix
new file mode 100644
index 0000000000000..7bf97d745fe47
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-pa.nix
@@ -0,0 +1,17 @@
+{
+  plasmaPackage,
+  ecm,
+  gconf, glib, kdoctools, kconfigwidgets, kcoreaddons, kdeclarative, kglobalaccel,
+  ki18n, libcanberra_gtk3, libpulseaudio, plasma-framework
+}:
+
+plasmaPackage {
+  name = "plasma-pa";
+  nativeBuildInputs = [
+    ecm kdoctools
+  ];
+  propagatedBuildInputs = [
+    gconf glib kconfigwidgets kcoreaddons kdeclarative
+    kglobalaccel ki18n libcanberra_gtk3 libpulseaudio plasma-framework
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/plasma-workspace-wallpapers.nix b/pkgs/desktops/plasma-5/plasma-workspace-wallpapers.nix
new file mode 100644
index 0000000000000..6ffdb17cbeab4
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-workspace-wallpapers.nix
@@ -0,0 +1,11 @@
+{ plasmaPackage
+, ecm
+}:
+
+plasmaPackage {
+  name = "plasma-workspace-wallpapers";
+  outputs = [ "out" ];
+  nativeBuildInputs = [
+    ecm
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/plasma-workspace/default.nix b/pkgs/desktops/plasma-5/plasma-workspace/default.nix
new file mode 100644
index 0000000000000..1e38c0c74dd4a
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-workspace/default.nix
@@ -0,0 +1,40 @@
+{
+  plasmaPackage, lib, copyPathsToStore,
+
+  ecm, kdoctools,
+
+  baloo, kactivities, kcmutils, kconfig, kcrash, kdbusaddons, kdeclarative,
+  kdelibs4support, kdesu, kglobalaccel, kidletime, kjsembed, knewstuff,
+  knotifyconfig, kpackage, krunner, ktexteditor, ktextwidgets, kwallet,
+  kwayland, kwin, kxmlrpcclient, libkscreen, libksysguard, networkmanager-qt,
+  phonon, plasma-framework, qtgraphicaleffects, qtquickcontrols, qtscript,
+  qtx11extras, solid, isocodes, libdbusmenu, libSM, libXcursor, pam, wayland
+}:
+
+plasmaPackage {
+  name = "plasma-workspace";
+
+  nativeBuildInputs = [ ecm kdoctools ];
+  buildInputs = [
+    baloo kactivities kcmutils kconfig kcrash kdbusaddons kdeclarative
+    kdelibs4support kdesu kglobalaccel kidletime kjsembed knewstuff
+    knotifyconfig kpackage krunner ktexteditor ktextwidgets kwallet kwayland
+    kwin kxmlrpcclient libkscreen libksysguard networkmanager-qt phonon
+    plasma-framework qtgraphicaleffects qtquickcontrols qtscript qtx11extras
+    solid isocodes libdbusmenu libSM libXcursor pam wayland
+  ];
+
+  patches = copyPathsToStore (lib.readPathsFromFile ./. ./series);
+
+  postPatch = ''
+    substituteInPlace startkde/kstartupconfig/kstartupconfig.cpp \
+        --replace kdostartupconfig5 $out/bin/kdostartupconfig5
+  '';
+
+  postInstall = ''
+    rm "$out/bin/startkde"
+    rm "$out/bin/startplasmacompositor"
+    rm "$out/lib/libexec/startplasma"
+    rm -r "$out/share/wayland-sessions"
+  '';
+}
diff --git a/pkgs/desktops/plasma-5/plasma-workspace/qml-import-path.patch b/pkgs/desktops/plasma-5/plasma-workspace/qml-import-path.patch
new file mode 100644
index 0000000000000..12eb65caa7171
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-workspace/qml-import-path.patch
@@ -0,0 +1,91 @@
+Index: plasma-workspace-5.6.3/applets/analog-clock/contents/ui/analogclock.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/analog-clock/contents/ui/analogclock.qml
++++ plasma-workspace-5.6.3/applets/analog-clock/contents/ui/analogclock.qml
+@@ -26,7 +26,7 @@ import QtQuick.Layouts 1.1
+ 
+ import org.kde.plasma.core 2.0 as PlasmaCore
+ import org.kde.plasma.components 2.0 as PlasmaComponents
+-import "logic.js" as Logic
++import "../code/logic.js" as Logic
+ 
+ Item {
+     id: analogclock
+Index: plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/BatteryItem.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/batterymonitor/package/contents/ui/BatteryItem.qml
++++ plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/BatteryItem.qml
+@@ -26,7 +26,7 @@ import org.kde.plasma.components 2.0 as
+ import org.kde.plasma.extras 2.0 as PlasmaExtras
+ import org.kde.plasma.workspace.components 2.0
+ import org.kde.kcoreaddons 1.0 as KCoreAddons
+-import "logic.js" as Logic
++import "../code/logic.js" as Logic
+ 
+ Item {
+     id: batteryItem
+Index: plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml
++++ plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml
+@@ -24,7 +24,7 @@ import QtQuick.Layouts 1.1
+ import org.kde.plasma.core 2.0 as PlasmaCore
+ import org.kde.plasma.components 2.0 as Components
+ import org.kde.plasma.workspace.components 2.0
+-import "logic.js" as Logic
++import "../code/logic.js" as Logic
+ 
+ MouseArea {
+     id: root
+Index: plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/PopupDialog.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/batterymonitor/package/contents/ui/PopupDialog.qml
++++ plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/PopupDialog.qml
+@@ -23,7 +23,7 @@ import org.kde.plasma.core 2.0 as Plasma
+ import org.kde.plasma.components 2.0 as Components
+ import org.kde.plasma.extras 2.0 as PlasmaExtras
+ import org.kde.kquickcontrolsaddons 2.0
+-import "logic.js" as Logic
++import "../code/logic.js" as Logic
+ 
+ FocusScope {
+     id: dialog
+Index: plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/batterymonitor.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/batterymonitor/package/contents/ui/batterymonitor.qml
++++ plasma-workspace-5.6.3/applets/batterymonitor/package/contents/ui/batterymonitor.qml
+@@ -25,7 +25,7 @@ import org.kde.plasma.plasmoid 2.0
+ import org.kde.plasma.core 2.0 as PlasmaCore
+ import org.kde.kcoreaddons 1.0 as KCoreAddons
+ import org.kde.kquickcontrolsaddons 2.0
+-import "logic.js" as Logic
++import "../code/logic.js" as Logic
+ 
+ Item {
+     id: batterymonitor
+Index: plasma-workspace-5.6.3/applets/lock_logout/contents/ui/lockout.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/lock_logout/contents/ui/lockout.qml
++++ plasma-workspace-5.6.3/applets/lock_logout/contents/ui/lockout.qml
+@@ -23,7 +23,7 @@ import org.kde.plasma.plasmoid 2.0
+ import org.kde.plasma.core 2.0 as PlasmaCore
+ import org.kde.plasma.components 2.0
+ import org.kde.kquickcontrolsaddons 2.0
+-import "data.js" as Data
++import "../code/data.js" as Data
+ 
+ Flow {
+     id: lockout
+Index: plasma-workspace-5.6.3/applets/notifications/package/contents/ui/main.qml
+===================================================================
+--- plasma-workspace-5.6.3.orig/applets/notifications/package/contents/ui/main.qml
++++ plasma-workspace-5.6.3/applets/notifications/package/contents/ui/main.qml
+@@ -28,7 +28,7 @@ import org.kde.plasma.extras 2.0 as Plas
+ 
+ import org.kde.plasma.private.notifications 1.0
+ 
+-import "uiproperties.js" as UiProperties
++import "../code/uiproperties.js" as UiProperties
+ 
+ MouseEventListener {
+     id: notificationsApplet
diff --git a/pkgs/desktops/plasma-5/plasma-workspace/series b/pkgs/desktops/plasma-5/plasma-workspace/series
new file mode 100644
index 0000000000000..b9081298bd693
--- /dev/null
+++ b/pkgs/desktops/plasma-5/plasma-workspace/series
@@ -0,0 +1 @@
+qml-import-path.patch
diff --git a/pkgs/desktops/plasma-5/polkit-kde-agent.nix b/pkgs/desktops/plasma-5/polkit-kde-agent.nix
new file mode 100644
index 0000000000000..002c2bb10ff30
--- /dev/null
+++ b/pkgs/desktops/plasma-5/polkit-kde-agent.nix
@@ -0,0 +1,14 @@
+{
+  plasmaPackage, ecm,
+  kcoreaddons, kconfig, kcrash, kdbusaddons, ki18n, kiconthemes, knotifications,
+  kwidgetsaddons, kwindowsystem, polkit-qt
+}:
+
+plasmaPackage {
+  name = "polkit-kde-agent";
+  nativeBuildInputs = [ ecm ];
+  propagatedBuildInputs = [
+    kdbusaddons kwidgetsaddons kcoreaddons kcrash kconfig ki18n kiconthemes
+    knotifications kwindowsystem polkit-qt
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/powerdevil.nix b/pkgs/desktops/plasma-5/powerdevil.nix
new file mode 100644
index 0000000000000..c0c18a6eae6cc
--- /dev/null
+++ b/pkgs/desktops/plasma-5/powerdevil.nix
@@ -0,0 +1,15 @@
+{ plasmaPackage, ecm, kdoctools, bluez-qt, kactivities
+, kauth, kconfig, kdbusaddons, kdelibs4support, kglobalaccel, ki18n
+, kidletime, kio, knotifyconfig, kwayland, libkscreen, networkmanager-qt
+, plasma-workspace, qtx11extras, solid, udev
+}:
+
+plasmaPackage {
+  name = "powerdevil";
+  nativeBuildInputs = [ ecm kdoctools ];
+  propagatedBuildInputs = [
+    kconfig kdbusaddons knotifyconfig solid udev bluez-qt kactivities kauth
+    kdelibs4support kglobalaccel ki18n kio kidletime kwayland libkscreen
+    networkmanager-qt plasma-workspace qtx11extras
+  ];
+}
diff --git a/pkgs/desktops/plasma-5/srcs.nix b/pkgs/desktops/plasma-5/srcs.nix
new file mode 100644
index 0000000000000..03ee867453b62
--- /dev/null
+++ b/pkgs/desktops/plasma-5/srcs.nix
@@ -0,0 +1,325 @@
+# DO NOT EDIT! This file is generated automatically by fetch-kde-qt.sh
+{ fetchurl, mirror }:
+
+{
+  bluedevil = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/bluedevil-5.8.5.tar.xz";
+      sha256 = "07gj3m5f0rk26n0xm4yddsfny6l2sh0airm45hb33p7m5inaqzgv";
+      name = "bluedevil-5.8.5.tar.xz";
+    };
+  };
+  breeze = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/breeze-5.8.5.tar.xz";
+      sha256 = "1gcns00iq7a5f1a0w6vf8zck669gzcd785fiybnvc6s6q8x4bp61";
+      name = "breeze-5.8.5.tar.xz";
+    };
+  };
+  breeze-grub = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/breeze-grub-5.8.5.tar.xz";
+      sha256 = "12ynrxdfcraphbwv9yrfhvwf3xkzrw0raqvgi7ksz5cvh78kl5qf";
+      name = "breeze-grub-5.8.5.tar.xz";
+    };
+  };
+  breeze-gtk = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/breeze-gtk-5.8.5.tar.xz";
+      sha256 = "15dx5hl9w9fiash30vgkbww6h7hck0dr42hh8gzysn0xyf0fzpgd";
+      name = "breeze-gtk-5.8.5.tar.xz";
+    };
+  };
+  breeze-plymouth = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/breeze-plymouth-5.8.5.tar.xz";
+      sha256 = "1ryb2jrzw0bzpi7ig4h5k0i33d2qviqsjxw7mnqxcb9q49a4ziq1";
+      name = "breeze-plymouth-5.8.5.tar.xz";
+    };
+  };
+  discover = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/discover-5.8.5.tar.xz";
+      sha256 = "0fr6mksqw46aghfzj78nlq3f89xd63vq2hr4c3gb4vkl5y8v08hg";
+      name = "discover-5.8.5.tar.xz";
+    };
+  };
+  kactivitymanagerd = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kactivitymanagerd-5.8.5.tar.xz";
+      sha256 = "07cqnbyznn5wy7vrqyid8h5ah7h3sb3pb30qlm83b4m29bkhggwh";
+      name = "kactivitymanagerd-5.8.5.tar.xz";
+    };
+  };
+  kde-cli-tools = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kde-cli-tools-5.8.5.tar.xz";
+      sha256 = "1ig9x5h9xkzis9izggkjpiiy4sm77pk347jdngx01qpacz68iyp7";
+      name = "kde-cli-tools-5.8.5.tar.xz";
+    };
+  };
+  kdecoration = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kdecoration-5.8.5.tar.xz";
+      sha256 = "1vhw57pj9i5224i9irk4qmingvkg5bip11vsqiwhmn5307bpnfiq";
+      name = "kdecoration-5.8.5.tar.xz";
+    };
+  };
+  kde-gtk-config = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kde-gtk-config-5.8.5.tar.xz";
+      sha256 = "1j0mzmmdhqd3a8papps6cad0gqn081mc4kqzi2hjai7038l6951r";
+      name = "kde-gtk-config-5.8.5.tar.xz";
+    };
+  };
+  kdeplasma-addons = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kdeplasma-addons-5.8.5.tar.xz";
+      sha256 = "181kagb4nbl9a7akk79slwkb7m2j4vyhabagih0z8l45wl5wrz9d";
+      name = "kdeplasma-addons-5.8.5.tar.xz";
+    };
+  };
+  kgamma5 = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kgamma5-5.8.5.tar.xz";
+      sha256 = "073z4w4i2hwsqqgxcfl0w8d57nhzc069h9zwp7fv93aaw4mgzci2";
+      name = "kgamma5-5.8.5.tar.xz";
+    };
+  };
+  khotkeys = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/khotkeys-5.8.5.tar.xz";
+      sha256 = "1fh0z9vfb908nbwj3snkf9z55jbcb5id87k5sa0v8dhazmp91ylh";
+      name = "khotkeys-5.8.5.tar.xz";
+    };
+  };
+  kinfocenter = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kinfocenter-5.8.5.tar.xz";
+      sha256 = "1fksnb9klbcrr9ly6dd2yx5y1ngcwcln43zykpc76pr4i49jpggp";
+      name = "kinfocenter-5.8.5.tar.xz";
+    };
+  };
+  kmenuedit = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kmenuedit-5.8.5.tar.xz";
+      sha256 = "1vq5f69w75lj81nz75db88lqxc4zvhicd5w7r6k7amggnwxm9f3m";
+      name = "kmenuedit-5.8.5.tar.xz";
+    };
+  };
+  kscreen = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kscreen-5.8.5.tar.xz";
+      sha256 = "069x3vsfqirmq8r7yfa68srhjvygdwsxcj0b4vvb7zivs29zn1mh";
+      name = "kscreen-5.8.5.tar.xz";
+    };
+  };
+  kscreenlocker = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kscreenlocker-5.8.5.tar.xz";
+      sha256 = "11b2v3chhk1ma5kjbmf35qahfr8gbaw78mcqs8vw5m9x74vlimkj";
+      name = "kscreenlocker-5.8.5.tar.xz";
+    };
+  };
+  ksshaskpass = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/ksshaskpass-5.8.5.tar.xz";
+      sha256 = "1gr48f4akrn0yhlnjw4yaas6ah5z40fb8iz06gi1dzry5axfmaxh";
+      name = "ksshaskpass-5.8.5.tar.xz";
+    };
+  };
+  ksysguard = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/ksysguard-5.8.5.tar.xz";
+      sha256 = "1gd81y2a459j5k1mpikfrvwcz7v09m526nrl7kpr4l4a1ps8zfy9";
+      name = "ksysguard-5.8.5.tar.xz";
+    };
+  };
+  kwallet-pam = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kwallet-pam-5.8.5.tar.xz";
+      sha256 = "0310vr3p9fxl3vwdgklk0acx6w31pcpq8mi9yldahg1mkjqf7l44";
+      name = "kwallet-pam-5.8.5.tar.xz";
+    };
+  };
+  kwayland-integration = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kwayland-integration-5.8.5.tar.xz";
+      sha256 = "11f63mq7crsbrpdib16q8xg0hk8jr5x1cyv43q8qdqm0591cglli";
+      name = "kwayland-integration-5.8.5.tar.xz";
+    };
+  };
+  kwin = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kwin-5.8.5.tar.xz";
+      sha256 = "182z17d4sad9j15qagx9yz13wwzcyy6hlgpy5nlx6dlfcb8s00x7";
+      name = "kwin-5.8.5.tar.xz";
+    };
+  };
+  kwrited = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/kwrited-5.8.5.tar.xz";
+      sha256 = "1nsr244niyq2bk29s0cqq1p2qj0h1hx4nl13nc3x3aycfhfkjfkr";
+      name = "kwrited-5.8.5.tar.xz";
+    };
+  };
+  libkscreen = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/libkscreen-5.8.5.tar.xz";
+      sha256 = "1zj2nzyl0nmg5za3iwr4q4nzfv69f35f0394b6k0g3dgh1zxmby9";
+      name = "libkscreen-5.8.5.tar.xz";
+    };
+  };
+  libksysguard = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/libksysguard-5.8.5.tar.xz";
+      sha256 = "1acp4kzdjhipsqw90n3rc1ydbkqhb12afwdsfl25fibv0c39avwp";
+      name = "libksysguard-5.8.5.tar.xz";
+    };
+  };
+  milou = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/milou-5.8.5.tar.xz";
+      sha256 = "0lj5cb43jkqs8qg2acs39dkfwskbw135ap65vxiv27ivxscyvz3d";
+      name = "milou-5.8.5.tar.xz";
+    };
+  };
+  oxygen = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/oxygen-5.8.5.tar.xz";
+      sha256 = "199jcn6qzyihxmw38b1cl0ah0rzn7f574khx72n9x5y9143p9lh7";
+      name = "oxygen-5.8.5.tar.xz";
+    };
+  };
+  plasma-desktop = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-desktop-5.8.5.tar.xz";
+      sha256 = "045990fvhqpwhfi6jqpkzhgbhc3lwvwhkia1y77m12n1djbynpnr";
+      name = "plasma-desktop-5.8.5.tar.xz";
+    };
+  };
+  plasma-integration = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-integration-5.8.5.tar.xz";
+      sha256 = "1sm7027ywz8xxqfsjv6jvk8zx11kx83rx88bb8cy31qfjipsakfb";
+      name = "plasma-integration-5.8.5.tar.xz";
+    };
+  };
+  plasma-nm = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-nm-5.8.5.tar.xz";
+      sha256 = "1g1yyzc8y2hsgycficvavpl5yizd54ns93cdky9cgsrnxlkfwbvc";
+      name = "plasma-nm-5.8.5.tar.xz";
+    };
+  };
+  plasma-pa = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-pa-5.8.5.tar.xz";
+      sha256 = "0vg1dyxfg8rxzyh0xnk41c95zp8rdbx1w462llrwchzp29p3xg1b";
+      name = "plasma-pa-5.8.5.tar.xz";
+    };
+  };
+  plasma-sdk = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-sdk-5.8.5.tar.xz";
+      sha256 = "13lyb5x4a8aq4fykvdv1137yvc4s4q31fdxhxppza1wkw8lvbvpd";
+      name = "plasma-sdk-5.8.5.tar.xz";
+    };
+  };
+  plasma-tests = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-tests-5.8.5.tar.xz";
+      sha256 = "0wgqyqlqygi3z0cccpfrpi259jp4yhh2g4x3mqcxisv58mbjrj1b";
+      name = "plasma-tests-5.8.5.tar.xz";
+    };
+  };
+  plasma-workspace = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-workspace-5.8.5.tar.xz";
+      sha256 = "18bf5wmyb198jnbpivjjwsk65sksrvzlvykx3mr3wvj30mr0f9bd";
+      name = "plasma-workspace-5.8.5.tar.xz";
+    };
+  };
+  plasma-workspace-wallpapers = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/plasma-workspace-wallpapers-5.8.5.tar.xz";
+      sha256 = "116s9qw888lbgxc9ggxf7fa99vggixr2ig1715xb5zmqm14yznyz";
+      name = "plasma-workspace-wallpapers-5.8.5.tar.xz";
+    };
+  };
+  polkit-kde-agent = {
+    version = "1-5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/polkit-kde-agent-1-5.8.5.tar.xz";
+      sha256 = "1dwk848wljcd9bi0h58h0ljnjlz1qq50rd7i38f3cb848iipisw7";
+      name = "polkit-kde-agent-1-5.8.5.tar.xz";
+    };
+  };
+  powerdevil = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/powerdevil-5.8.5.tar.xz";
+      sha256 = "0lj7jcaqfsipiwi7x4q684p4pfsqzflvddr7hrhirfl1p62bc704";
+      name = "powerdevil-5.8.5.tar.xz";
+    };
+  };
+  sddm-kcm = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/sddm-kcm-5.8.5.tar.xz";
+      sha256 = "0dcvk3f3cqq4z5hc63ccpxyl3kknjvd8jsnx7r2hfrwsw0y90fqc";
+      name = "sddm-kcm-5.8.5.tar.xz";
+    };
+  };
+  systemsettings = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/systemsettings-5.8.5.tar.xz";
+      sha256 = "0pkwmgbjglbyc8i22hivh5gnaj742df3ff3f998k66k81mfjkwga";
+      name = "systemsettings-5.8.5.tar.xz";
+    };
+  };
+  user-manager = {
+    version = "5.8.5";
+    src = fetchurl {
+      url = "${mirror}/stable/plasma/5.8.5/user-manager-5.8.5.tar.xz";
+      sha256 = "1ck8x860q3aqgbbgiwfdhs0i0bs2nhqqva19kl9x1b015p64gl5z";
+      name = "user-manager-5.8.5.tar.xz";
+    };
+  };
+}
diff --git a/pkgs/desktops/plasma-5/startkde/default.nix b/pkgs/desktops/plasma-5/startkde/default.nix
new file mode 100644
index 0000000000000..516d651cec25c
--- /dev/null
+++ b/pkgs/desktops/plasma-5/startkde/default.nix
@@ -0,0 +1,54 @@
+{
+  stdenv, lib, runCommand, dbus, qttools, socat, gnugrep, gnused, kconfig,
+  kinit, kservice, plasma-workspace, xmessage, xprop, xsetroot, qtbase,
+  qtdeclarative, qtgraphicaleffects, qtquickcontrols, qtscript, qtsvg,
+  qtx11extras, qtxmlpatterns
+}:
+
+let
+
+  env = {
+    inherit (stdenv) shell;
+    bins = builtins.map (pkg: pkg.out or pkg)
+      [
+        dbus qttools socat
+        gnugrep gnused
+        kconfig kinit kservice
+        plasma-workspace
+        xmessage xprop xsetroot
+      ];
+    libs = builtins.map (pkg: pkg.out or pkg)
+      [
+        qtbase qtdeclarative qtgraphicaleffects qtquickcontrols
+        qtscript qtsvg qtx11extras qtxmlpatterns
+      ];
+  };
+
+in runCommand "startkde" env ''
+
+  # Configure PATH variable
+  suffixPATH=
+  for p in $bins; do
+      addToSearchPath suffixPATH "$p/bin"
+      addToSearchPath suffixPATH "$p/lib/libexec"
+      addToSearchPath suffixPATH "$p/lib/libexec/kf5"
+  done
+
+  # Configure Qt search paths
+  QT_PLUGIN_PATH=
+  QML_IMPORT_PATH=
+  QML2_IMPORT_PATH=
+  for p in $libs; do
+      addToSearchPath QT_PLUGIN_PATH "$p/lib/qt5/plugins"
+      addToSearchPath QML_IMPORT_PATH "$p/lib/qt5/imports"
+      addToSearchPath QML2_IMPORT_PATH "$p/lib/qt5/qml"
+  done
+
+  substitute ${./startkde.sh} "$out" \
+      --subst-var shell \
+      --subst-var suffixPATH \
+      --subst-var QT_PLUGIN_PATH \
+      --subst-var QML_IMPORT_PATH \
+      --subst-var QML2_IMPORT_PATH
+  chmod +x "$out"
+''
diff --git a/pkgs/desktops/plasma-5/startkde/startkde.sh b/pkgs/desktops/plasma-5/startkde/startkde.sh
new file mode 100755
index 0000000000000..a403e8e05e6ee
--- /dev/null
+++ b/pkgs/desktops/plasma-5/startkde/startkde.sh
@@ -0,0 +1,385 @@
+#!@shell@
+
+PATH="$PATH${PATH:+:}@suffixPATH@"
+
+export QT_PLUGIN_PATH="$QT_PLUGIN_PATH${QT_PLUGIN_PATH:+:}@QT_PLUGIN_PATH@"
+export QML_IMPORT_PATH="$QML_IMPORT_PATH${QML_IMPORT_PATH:+:}@QML_IMPORT_PATH@"
+export QML2_IMPORT_PATH="$QML2_IMPORT_PATH${QML2_IMPORT_PATH:+:}@QML2_IMPORT_PATH@"
+
+kbuildsycoca5
+
+# Set the default GTK 2 theme
+if ! [ -e $HOME/.gtkrc-2.0 ] \
+     && [ -e /run/current-system/sw/share/themes/Breeze/gtk-2.0/gtkrc ]; then
+    cat >$HOME/.gtkrc-2.0 <<EOF
+# Default GTK+ 2 config for NixOS KDE 5
+include "/run/current-system/sw/share/themes/Breeze/gtk-2.0/gtkrc"
+gtk-theme-name="Breeze"
+gtk-icon-theme-name="breeze"
+gtk-fallback-icon-theme="hicolor"
+gtk-cursor-theme-name="breeze_cursors"
+gtk-toolbar-style=GTK_TOOLBAR_ICONS
+gtk-menu-images=1
+gtk-button-images=1
+EOF
+fi
+
+if ! [ -e $HOME/.config/gtk-3.0/settings.ini ] \
+       && [ -e /run/current-system/sw/share/themes/Breeze/gtk-3.0 ]; then
+    cat >$HOME/.config/gtk-3.0/settings.ini <<EOF
+[Settings]
+gtk-theme-name=Breeze
+gtk-icon-theme-name=breeze
+gtk-fallback-icon-theme=hicolor
+gtk-cursor-theme-name=breeze_cursors
+gtk-toolbar-style=GTK_TOOLBAR_ICONS
+gtk-menu-images=1
+gtk-button-images=1
+EOF
+fi
+
+# The KDE icon cache is supposed to update itself
+# automatically, but it uses the timestamp on the icon
+# theme directory as a trigger.  Since in Nix the
+# timestamp is always the same, this doesn't work.  So as
+# a workaround, nuke the icon cache on login.  This isn't
+# perfect, since it may require logging out after
+# installing new applications to update the cache.
+# See http://lists-archives.org/kde-devel/26175-what-when-will-icon-cache-refresh.html
+rm -fv $HOME/.cache/icon-cache.kcache
+
+# Qt writes a weird ‘libraryPath’ line to
+# ~/.config/Trolltech.conf that causes the KDE plugin
+# paths of previous KDE invocations to be searched.
+# Obviously using mismatching KDE libraries is potentially
+# disastrous, so here we nuke references to the Nix store
+# in Trolltech.conf.  A better solution would be to stop
+# Qt from doing this wackiness in the first place.
+if [ -e $HOME/.config/Trolltech.conf ]; then
+    sed -e '/nix\\store\|nix\/store/ d' -i $HOME/.config/Trolltech.conf
+fi
+
+if test "x$1" = x--failsafe; then
+    KDE_FAILSAFE=1 # General failsafe flag
+    KWIN_COMPOSE=N # Disable KWin's compositing
+    QT_XCB_FORCE_SOFTWARE_OPENGL=1
+    export KWIN_COMPOSE KDE_FAILSAFE QT_XCB_FORCE_SOFTWARE_OPENGL
+fi
+
+# When the X server dies we get a HUP signal from xinit. We must ignore it
+# because we still need to do some cleanup.
+trap 'echo GOT SIGHUP' HUP
+
+# we have to unset this for Darwin since it will screw up KDE's dynamic-loading
+unset DYLD_FORCE_FLAT_NAMESPACE
+
+# Check if a KDE session already is running and whether it's possible to connect to X
+kcheckrunning
+kcheckrunning_result=$?
+if test $kcheckrunning_result -eq 0 ; then
+    echo "KDE seems to be already running on this display."
+    xmessage -geometry 500x100 "KDE seems to be already running on this display."
+	exit 1
+elif test $kcheckrunning_result -eq 2 ; then
+	echo "\$DISPLAY is not set or cannot connect to the X server."
+    exit 1
+fi
+
+# Boot sequence:
+#
+# kdeinit is used to fork off processes which improves memory usage
+# and startup time.
+#
+# * kdeinit starts klauncher first.
+# * Then kded is started. kded is responsible for keeping the sycoca
+#   database up to date. When an up to date database is present it goes
+#   into the background and the startup continues.
+# * Then kdeinit starts kcminit. kcminit performs initialisation of
+#   certain devices according to the user's settings
+#
+# * Then ksmserver is started which takes control of the rest of the startup sequence
+
+# We need to create config folder so we can write startupconfigkeys
+configDir=$(qtpaths --writable-path GenericConfigLocation)
+mkdir -p "$configDir"
+
+if ! [ -e $configDir/kcminputrc ]; then
+    cat >$configDir/kcminputrc <<EOF
+[Mouse]
+cursorTheme=breeze_cursors
+cursorSize=0
+EOF
+fi
+
+THEME=org.kde.breeze
+#This is basically setting defaults so we can use them with kstartupconfig5
+#We cannot set the equivilant of THEME here as it will generate an
+#invalid variable name (with dots)
+cat >$configDir/startupconfigkeys <<EOF
+kcminputrc Mouse cursorTheme 'breeze_cursors'
+kcminputrc Mouse cursorSize ''
+ksplashrc KSplash Theme ${THEME}.desktop
+ksplashrc KSplash Engine KSplashQML
+kdeglobals KScreen ScreenScaleFactors ''
+kcmfonts General forceFontDPI 0
+EOF
+
+# preload the user's locale on first start
+plasmalocalerc=$configDir/plasma-localerc
+test -f $plasmalocalerc || {
+cat >$plasmalocalerc <<EOF
+[Formats]
+LANG=$LANG
+EOF
+}
+
+# export LC_* variables set by kcmshell5 formats into environment
+# so it can be picked up by QLocale and friends.
+exportformatssettings=$configDir/plasma-locale-settings.sh
+test -f $exportformatssettings && {
+    . $exportformatssettings
+}
+
+# Write a default kdeglobals file to set up the font
+kdeglobalsfile=$configDir/kdeglobals
+test -f $kdeglobalsfile || {
+cat >$kdeglobalsfile <<EOF
+[General]
+XftAntialias=true
+XftHintStyle=hintmedium
+XftSubPixel=none
+EOF
+}
+
+kstartupconfig5
+returncode=$?
+if test $returncode -ne 0; then
+    xmessage -geometry 500x100 "kstartupconfig5 does not exist or fails. The error code is $returncode. Check your installation."
+    exit 1
+fi
+[ -r $configDir/startupconfig ] && . $configDir/startupconfig
+
+if [ "$kdeglobals_kscreen_screenscalefactors" ]; then
+    export QT_SCREEN_SCALE_FACTORS="$kdeglobals_kscreen_screenscalefactors"
+fi
+#Manually disable auto scaling because we are scaling above
+#otherwise apps that manually opt in for high DPI get auto scaled by the developer AND manually scaled by us
+export QT_AUTO_SCREEN_SCALE_FACTOR=0
+
+XCURSOR_PATH=~/.icons
+IFS=":" read -r -a xdgDirs <<< "$XDG_DATA_DIRS"
+for xdgDir in "${xdgDirs[@]}"; do
+    XCURSOR_PATH="$XCURSOR_PATH:$xdgDir/icons"
+done
+export XCURSOR_PATH
+
+# XCursor mouse theme needs to be applied here to work even for kded or ksmserver
+if test -n "$kcminputrc_mouse_cursortheme" -o -n "$kcminputrc_mouse_cursorsize" ; then
+
+    kapplymousetheme "$kcminputrc_mouse_cursortheme" "$kcminputrc_mouse_cursorsize"
+    if test $? -eq 10; then
+        XCURSOR_THEME=breeze_cursors
+        export XCURSOR_THEME
+    elif test -n "$kcminputrc_mouse_cursortheme"; then
+        XCURSOR_THEME="$kcminputrc_mouse_cursortheme"
+        export XCURSOR_THEME
+    fi
+    if test -n "$kcminputrc_mouse_cursorsize"; then
+        XCURSOR_SIZE="$kcminputrc_mouse_cursorsize"
+        export XCURSOR_SIZE
+    fi
+fi
+
+unset THEME
+
+# Set a left cursor instead of the standard X11 "X" cursor, since I've heard
+# from some users that they're confused and don't know what to do. This is
+# especially necessary on slow machines, where starting KDE takes one or two
+# minutes until anything appears on the screen.
+#
+# If the user has overwritten fonts, the cursor font may be different now
+# so don't move this up.
+#
+xsetroot -cursor_name left_ptr
+
+if test "$kcmfonts_general_forcefontdpi" -ne 0; then
+    xrdb -quiet -merge -nocpp <<EOF
+Xft.dpi: $kcmfonts_general_forcefontdpi
+EOF
+fi
+
+dl=$DESKTOP_LOCKED
+unset DESKTOP_LOCKED # Don't want it in the environment
+
+ksplash_pid=
+if test -z "$dl"; then
+  # the splashscreen and progress indicator
+  case "$ksplashrc_ksplash_engine" in
+    KSplashQML)
+      ksplash_pid=$(ksplashqml "${ksplashrc_ksplash_theme}" --pid)
+      ;;
+    None)
+      ;;
+    *)
+      ;;
+  esac
+fi
+
+echo 'startkde: Starting up...'  1>&2
+
+# Make sure that D-Bus is running
+if qdbus >/dev/null 2>/dev/null; then
+    : # ok
+else
+    echo 'startkde: Could not start D-Bus. Can you call qdbus?'  1>&2
+    test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
+    xmessage -geometry 500x100 "Could not start D-Bus. Can you call qdbus?"
+    exit 1
+fi
+
+# Mark that full KDE session is running (e.g. Konqueror preloading works only
+# with full KDE running). The KDE_FULL_SESSION property can be detected by
+# any X client connected to the same X session, even if not launched
+# directly from the KDE session but e.g. using "ssh -X", kdesu. $KDE_FULL_SESSION
+# however guarantees that the application is launched in the same environment
+# like the KDE session and that e.g. KDE utilities/libraries are available.
+# KDE_FULL_SESSION property is also only available since KDE 3.5.5.
+# The matching tests are:
+#   For $KDE_FULL_SESSION:
+#     if test -n "$KDE_FULL_SESSION"; then ... whatever
+#   For KDE_FULL_SESSION property:
+#     xprop -root | grep "^KDE_FULL_SESSION" >/dev/null 2>/dev/null
+#     if test $? -eq 0; then ... whatever
+#
+# Additionally there is (since KDE 3.5.7) $KDE_SESSION_UID with the uid
+# of the user running the KDE session. It should be rarely needed (e.g.
+# after sudo to prevent desktop-wide functionality in the new user's kded).
+#
+# Since KDE4 there is also KDE_SESSION_VERSION, containing the major version number.
+# Note that this didn't exist in KDE3, which can be detected by its absense and
+# the presence of KDE_FULL_SESSION.
+#
+KDE_FULL_SESSION=true
+export KDE_FULL_SESSION
+xprop -root -f KDE_FULL_SESSION 8t -set KDE_FULL_SESSION true
+
+KDE_SESSION_VERSION=5
+export KDE_SESSION_VERSION
+xprop -root -f KDE_SESSION_VERSION 32c -set KDE_SESSION_VERSION 5
+
+KDE_SESSION_UID=$(id -ru)
+export KDE_SESSION_UID
+
+XDG_CURRENT_DESKTOP=KDE
+export XDG_CURRENT_DESKTOP
+
+# Source scripts found in <config locations>/plasma-workspace/env/*.sh
+# (where <config locations> correspond to the system and user's configuration
+# directories, as identified by Qt's qtpaths,  e.g.  $HOME/.config
+# and /etc/xdg/ on Linux)
+#
+# This is where you can define environment variables that will be available to
+# all KDE programs, so this is where you can run agents using e.g. eval `ssh-agent`
+# or eval `gpg-agent --daemon`.
+# Note: if you do that, you should also put "ssh-agent -k" as a shutdown script
+#
+# (see end of this file).
+# For anything else (that doesn't set env vars, or that needs a window manager),
+# better use the Autostart folder.
+
+IFS=":" read -r -a scriptpath <<< $(qtpaths --paths GenericConfigLocation)
+# Add /env/ to the directory to locate the scripts to be sourced
+for prefix in "${scriptpath[@]}"; do
+  for file in "$prefix"/plasma-workspace/env/*.sh; do
+    test -r "$file" && . "$file" || true
+  done
+done
+
+# At this point all the environment is ready, let's send it to kwalletd if running
+if test -n "$PAM_KWALLET_LOGIN" ; then
+    env | socat STDIN UNIX-CONNECT:$PAM_KWALLET_LOGIN
+fi
+# ...and also to kwalletd5
+if test -n "$PAM_KWALLET5_LOGIN" ; then
+    env | socat STDIN UNIX-CONNECT:$PAM_KWALLET5_LOGIN
+fi
+
+# At this point all environment variables are set, let's send it to the DBus session server to update the activation environment
+dbus-update-activation-environment --systemd --all
+if test $? -ne 0; then
+  # Startup error
+  echo 'startkde: Could not sync environment to dbus.'  1>&2
+  test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
+  xmessage -geometry 500x100 "Could not sync environment to dbus."
+  exit 1
+fi
+
+# We set LD_BIND_NOW to increase the efficiency of kdeinit.
+# kdeinit unsets this variable before loading applications.
+LD_BIND_NOW=true start_kdeinit_wrapper --kded +kcminit_startup
+if test $? -ne 0; then
+  # Startup error
+  echo 'startkde: Could not start kdeinit5. Check your installation.'  1>&2
+  test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
+  xmessage -geometry 500x100 "Could not start kdeinit5. Check your installation."
+  exit 1
+fi
+
+qdbus org.kde.KSplash /KSplash org.kde.KSplash.setStage kinit
+
+# finally, give the session control to the session manager
+# see kdebase/ksmserver for the description of the rest of the startup sequence
+# if the KDEWM environment variable has been set, then it will be used as KDE's
+# window manager instead of kwin.
+# if KDEWM is not set, ksmserver will ensure kwin is started.
+# kwrapper5 is used to reduce startup time and memory usage
+# kwrapper5 does not return useful error codes such as the exit code of ksmserver.
+# We only check for 255 which means that the ksmserver process could not be
+# started, any problems thereafter, e.g. ksmserver failing to initialize,
+# will remain undetected.
+test -n "$KDEWM" && KDEWM="--windowmanager $KDEWM"
+# If the session should be locked from the start (locked autologin),
+# lock now and do the rest of the KDE startup underneath the locker.
+KSMSERVEROPTIONS=""
+test -n "$dl" && KSMSERVEROPTIONS=" --lockscreen"
+kwrapper5 ksmserver $KDEWM $KSMSERVEROPTIONS
+if test $? -eq 255; then
+  # Startup error
+  echo 'startkde: Could not start ksmserver. Check your installation.'  1>&2
+  test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
+  xmessage -geometry 500x100 "Could not start ksmserver. Check your installation."
+fi
+
+wait_drkonqi=$(kreadconfig5 --file startkderc --group WaitForDrKonqi --key Enabled --default true)
+
+if test x"$wait_drkonqi"x = x"true"x ; then
+    # wait for remaining drkonqi instances with timeout (in seconds)
+    wait_drkonqi_timeout=$(kreadconfig5 --file startkderc --group WaitForDrKonqi --key Timeout --default 900)
+    wait_drkonqi_counter=0
+    while qdbus | grep "^[^w]*org.kde.drkonqi" > /dev/null ; do
+        sleep 5
+        wait_drkonqi_counter=$((wait_drkonqi_counter+5))
+        if test "$wait_drkonqi_counter" -ge "$wait_drkonqi_timeout" ; then
+            # ask remaining drkonqis to die in a graceful way
+            qdbus | grep 'org.kde.drkonqi-' | while read address ; do
+                qdbus "$address" "/MainApplication" "quit"
+            done
+            break
+        fi
+    done
+fi
+
+echo 'startkde: Shutting down...'  1>&2
+# just in case
+test -n "$ksplash_pid" && kill "$ksplash_pid" 2>/dev/null
+
+# Clean up
+kdeinit5_shutdown
+
+unset KDE_FULL_SESSION
+xprop -root -remove KDE_FULL_SESSION
+unset KDE_SESSION_VERSION
+xprop -root -remove KDE_SESSION_VERSION
+unset KDE_SESSION_UID
+
+echo 'startkde: Done.'  1>&2
diff --git a/pkgs/desktops/plasma-5/systemsettings.nix b/pkgs/desktops/plasma-5/systemsettings.nix
new file mode 100644
index 0000000000000..407d0e916264b
--- /dev/null
+++ b/pkgs/desktops/plasma-5/systemsettings.nix
@@ -0,0 +1,14 @@
+{
+  plasmaPackage, ecm, kdoctools, makeQtWrapper,
+  kcmutils, kconfig, kdbusaddons, khtml, ki18n, kiconthemes, kio, kitemviews,
+  kservice, kwindowsystem, kxmlgui, qtquickcontrols
+}:
+
+plasmaPackage {
+  name = "systemsettings";
+  nativeBuildInputs = [ ecm kdoctools makeQtWrapper ];
+  propagatedBuildInputs = [
+    kcmutils kconfig kdbusaddons khtml ki18n kiconthemes kio kitemviews kservice
+    kwindowsystem kxmlgui qtquickcontrols
+  ];
+}