diff --git a/nixos/modules/services/x11/desktop-managers/plasma5.nix b/nixos/modules/services/x11/desktop-managers/plasma5.nix index 8a1793484e23e..9bacdaa9be984 100644 --- a/nixos/modules/services/x11/desktop-managers/plasma5.nix +++ b/nixos/modules/services/x11/desktop-managers/plasma5.nix @@ -4,6 +4,28 @@ let xcfg = config.services.xserver; cfg = xcfg.desktopManager.plasma5; + # Use only for **internal** options. + # This is not exactly user-friendly. + kdeConfigurationType = with types; + let + valueTypes = (oneOf [ + bool + float + int + str + ]) // { + description = "KDE Configuration value"; + emptyValue.value = ""; + }; + set = (nullOr (lazyAttrsOf valueTypes)) // { + description = "KDE Configuration set"; + emptyValue.value = {}; + }; + in (lazyAttrsOf set) // { + description = "KDE Configuration file"; + emptyValue.value = {}; + }; + libsForQt5 = pkgs.plasma5Packages; inherit (libsForQt5) kdeGear kdeFrameworks plasma5; inherit (pkgs) writeText; @@ -169,6 +191,37 @@ in type = types.bool; default = false; }; + + # Internally allows configuring kdeglobals globally + kdeglobals = mkOption { + internal = true; + default = {}; + type = kdeConfigurationType; + }; + + # Internally allows configuring kwin globally + kwinrc = mkOption { + internal = true; + default = {}; + type = kdeConfigurationType; + }; + + mobile.enable = mkOption { + type = types.bool; + default = false; + description = '' + Enable support for running the Plasma Mobile shell. + ''; + }; + + mobile.installRecommendedSoftware = mkOption { + type = types.bool; + default = true; + description = '' + Installs software recommended for use with Plasma Mobile, but which + is not strictly required for Plasma Mobile to run. + ''; + }; }; imports = [ @@ -177,22 +230,8 @@ in ]; config = mkMerge [ - (mkIf cfg.enable { - - # Seed our configuration into nixos-generate-config - system.nixos-generate-config.desktopConfiguration = [ - '' - # Enable the Plasma 5 Desktop Environment. - services.xserver.displayManager.sddm.enable = true; - services.xserver.desktopManager.plasma5.enable = true; - '' - ]; - - services.xserver.displayManager.sessionPackages = [ pkgs.libsForQt5.plasma5.plasma-workspace ]; - # Default to be `plasma` (X11) instead of `plasmawayland`, since plasma wayland currently has - # many tiny bugs. - # See: https://github.com/NixOS/nixpkgs/issues/143272 - services.xserver.displayManager.defaultSession = mkDefault "plasma"; + # Common Plasma dependencies + (mkIf (cfg.enable || cfg.mobile.enable) { security.wrappers = { kcheckpass = { @@ -278,37 +317,24 @@ in kdeplasma-addons kgamma5 khotkeys - kinfocenter - kmenuedit kscreen kscreenlocker - ksystemstats kwayland kwin kwrited libkscreen libksysguard milou - plasma-systemmonitor plasma-browser-integration plasma-integration polkit-kde-agent - spectacle - systemsettings plasma-desktop plasma-workspace plasma-workspace-wallpapers - dolphin - dolphin-plugins - ffmpegthumbs - kdegraphics-thumbnailers - khelpcenter - kio-extras konsole oxygen - print-manager breeze-icons pkgs.hicolor-icon-theme @@ -319,10 +345,6 @@ in qtvirtualkeyboard pkgs.xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/ - - elisa - gwenview - okular ] # Phonon audio backend @@ -396,7 +418,67 @@ in serviceConfig.Type = "oneshot"; script = activationScript; }; + }; + + xdg.portal.enable = true; + xdg.portal.extraPortals = [ plasma5.xdg-desktop-portal-kde ]; + + # Update the start menu for each user that is currently logged in + system.userActivationScripts.plasmaSetup = activationScript; + services.xserver.displayManager.setupCommands = startplasma; + + nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true; + + environment.etc = { + "xdg/kwinrc".text = lib.generators.toINI {} cfg.kwinrc; + "xdg/kdeglobals".text = lib.generators.toINI {} cfg.kdeglobals; + }; + }) + + # Plasma Desktop + (mkIf cfg.enable { + + # Seed our configuration into nixos-generate-config + system.nixos-generate-config.desktopConfiguration = [ + '' + # Enable the Plasma 5 Desktop Environment. + services.xserver.displayManager.sddm.enable = true; + services.xserver.desktopManager.plasma5.enable = true; + '' + ]; + services.xserver.displayManager.sessionPackages = [ pkgs.libsForQt5.plasma5.plasma-workspace ]; + # Default to be `plasma` (X11) instead of `plasmawayland`, since plasma wayland currently has + # many tiny bugs. + # See: https://github.com/NixOS/nixpkgs/issues/143272 + services.xserver.displayManager.defaultSession = mkDefault "plasma"; + + environment.systemPackages = + with libsForQt5; + with plasma5; with kdeGear; with kdeFrameworks; + [ + ksystemstats + kinfocenter + kmenuedit + plasma-systemmonitor + spectacle + systemsettings + + dolphin + dolphin-plugins + ffmpegthumbs + kdegraphics-thumbnailers + khelpcenter + kio-extras + print-manager + + elisa + gwenview + okular + ] + ; + + systemd.user.services = { plasma-run-with-systemd = { description = "Run KDE Plasma via systemd"; wantedBy = [ "basic.target" ]; @@ -409,15 +491,88 @@ in ''; }; }; + }) - xdg.portal.enable = true; - xdg.portal.extraPortals = [ plasma5.xdg-desktop-portal-kde ]; + # Plasma Mobile + (mkIf cfg.mobile.enable { + assertions = [ + { + # The user interface breaks without NetworkManager + assertion = config.networking.networkmanager.enable; + message = "Plasma Mobile requires NetworkManager."; + } + { + # The user interface breaks without bluetooth + assertion = config.hardware.bluetooth.enable; + message = "Plasma Mobile requires Bluetooth."; + } + { + # The user interface breaks without pulse + assertion = config.hardware.pulseaudio.enable; + message = "Plasma Mobile requires pulseaudio."; + } + ]; - # Update the start menu for each user that is currently logged in - system.userActivationScripts.plasmaSetup = activationScript; - services.xserver.displayManager.setupCommands = startplasma; + environment.systemPackages = + with libsForQt5; + with plasma5; with kdeApplications; with kdeFrameworks; + [ + # Basic packages without which Plasma Mobile fails to work properly. + plasma-phone-components + plasma-nano + pkgs.maliit-framework + pkgs.maliit-keyboard + ] + ++ lib.optionals (cfg.mobile.installRecommendedSoftware) (with libsForQt5.plasmaMobileGear;[ + # Additional software made for Plasma Mobile. + alligator + angelfish + audiotube + calindori + kalk + kasts + kclock + keysmith + koko + krecorder + ktrip + kweather + plasma-dialer + plasma-phonebook + plasma-settings + spacebar + ]) + ; + + # The following services are needed or the UI is broken. + hardware.bluetooth.enable = true; + hardware.pulseaudio.enable = true; + networking.networkmanager.enable = true; + + # Recommendations can be found here: + # - https://invent.kde.org/plasma-mobile/plasma-phone-settings/-/tree/master/etc/xdg + # This configuration is the minimum required for Plasma Mobile to *work*. + services.xserver.desktopManager.plasma5 = { + kdeglobals = { + KDE = { + # This forces a numeric PIN for the lockscreen, which is the + # recommendation from upstream. + LookAndFeelPackage = lib.mkDefault "org.kde.plasma.phone"; + }; + }; + kwinrc = { + Windows = { + # Forces windows to be maximized + Placement = lib.mkDefault "Maximizing"; + }; + "org.kde.kdecoration2" = { + # No decorations (title bar) + NoPlugin = lib.mkDefault "true"; + }; + }; + }; - nixpkgs.config.firefox.enablePlasmaBrowserIntegration = true; + services.xserver.displayManager.sessionPackages = [ pkgs.libsForQt5.plasma5.plasma-phone-components ]; }) ]; } diff --git a/pkgs/applications/misc/maliit-framework/default.nix b/pkgs/applications/misc/maliit-framework/default.nix new file mode 100644 index 0000000000000..6a6e66f293bda --- /dev/null +++ b/pkgs/applications/misc/maliit-framework/default.nix @@ -0,0 +1,68 @@ +{ mkDerivation +, lib +, fetchFromGitHub + +, at-spi2-atk +, at-spi2-core +, libepoxy +, gtk3 +, libdatrie +, libselinux +, libsepol +, libthai +, pcre +, util-linux +, wayland +, xorg + +, cmake +, doxygen +, pkg-config +, wayland-protocols +}: + +mkDerivation rec { + pname = "maliit-framework"; + version = "2.0.0"; + + src = fetchFromGitHub { + owner = "maliit"; + repo = "framework"; + rev = version; + sha256 = "138jyvw130kmrldksbk4l38gvvahh3x51zi4vyplad0z5nxmbazb"; + }; + + buildInputs = [ + at-spi2-atk + at-spi2-core + libepoxy + gtk3 + libdatrie + libselinux + libsepol + libthai + pcre + util-linux + wayland + xorg.libXdmcp + xorg.libXtst + ]; + + nativeBuildInputs = [ + cmake + doxygen + pkg-config + wayland-protocols + ]; + + preConfigure = '' + cmakeFlags+="-DQT5_PLUGINS_INSTALL_DIR=$out/$qtPluginPrefix" + ''; + + meta = with lib; { + description = "Core libraries of Maliit and server"; + homepage = "http://maliit.github.io/"; + license = licenses.lgpl21Plus; + maintainers = with maintainers; [ samueldr ]; + }; +} diff --git a/pkgs/applications/misc/maliit-keyboard/default.nix b/pkgs/applications/misc/maliit-keyboard/default.nix new file mode 100644 index 0000000000000..fcbd6cbff19bd --- /dev/null +++ b/pkgs/applications/misc/maliit-keyboard/default.nix @@ -0,0 +1,82 @@ +{ mkDerivation +, lib +, fetchFromGitHub +, fetchpatch + +, anthy +, hunspell +, libchewing +, libpinyin +, maliit-framework +, pcre +, presage +, qtfeedback +, qtmultimedia +, qtquickcontrols2 +, qtgraphicaleffects + +, cmake +, pkg-config +, wrapGAppsHook +}: + +mkDerivation rec { + pname = "maliit-keyboard"; + version = "2.0.0"; + + src = fetchFromGitHub { + owner = "maliit"; + repo = "keyboard"; + rev = version; + sha256 = "10dh0abxq90024dqq3fs8mjxww3igb4l09d19i2fq9f3flvh11hc"; + }; + + patches = [ + (fetchpatch { + # https://github.com/maliit/keyboard/pull/34 + url = "https://github.com/maliit/keyboard/commit/9848a73b737ad46b5790ebf713a559d340c91b82.patch"; + sha256 = "0qrsga0npahjrgbl6mycvl6d6vjm0d17i5jadcn7y6khbhq2y6rg"; + }) + ]; + + postPatch = '' + substituteInPlace data/schemas/org.maliit.keyboard.maliit.gschema.xml \ + --replace /usr/share "$out/share" + ''; + + buildInputs = [ + anthy + hunspell + libchewing + libpinyin + maliit-framework + pcre + presage + qtfeedback + qtmultimedia + qtquickcontrols2 + qtgraphicaleffects + ]; + + cmakeFlags = [ + "-DCMAKE_INSTALL_PREFIX=${placeholder "out"}" + "-DCMAKE_INSTALL_LIBDIR=lib" + ]; + + nativeBuildInputs = [ + cmake + pkg-config + wrapGAppsHook + ]; + + postInstall = '' + glib-compile-schemas "$out"/share/glib-2.0/schemas + ''; + + meta = with lib; { + description = "Virtual keyboard"; + homepage = "http://maliit.github.io/"; + license = with licenses; [ lgpl3Only bsd3 cc-by-30 ]; + maintainers = with maintainers; [ samueldr ]; + }; +} diff --git a/pkgs/applications/plasma-mobile/default.nix b/pkgs/applications/plasma-mobile/default.nix index fd9ae2a2bae84..10c1f1d0e9bc8 100644 --- a/pkgs/applications/plasma-mobile/default.nix +++ b/pkgs/applications/plasma-mobile/default.nix @@ -75,6 +75,7 @@ let kweather = callPackage ./kweather.nix {}; plasma-dialer = callPackage ./plasma-dialer.nix {}; plasma-phonebook = callPackage ./plasma-phonebook.nix {}; + plasma-settings = callPackage ./plasma-settings.nix {}; spacebar = callPackage ./spacebar.nix {}; }; diff --git a/pkgs/applications/plasma-mobile/plasma-settings.nix b/pkgs/applications/plasma-mobile/plasma-settings.nix new file mode 100644 index 0000000000000..bcd04dadca22c --- /dev/null +++ b/pkgs/applications/plasma-mobile/plasma-settings.nix @@ -0,0 +1,42 @@ +{ lib +, mkDerivation +, fetchFromGitLab + +, cmake +, extra-cmake-modules + +, kauth +, kconfig +, kcoreaddons +, kdbusaddons +, ki18n +, kitemmodels +, plasma-framework +}: + +mkDerivation rec { + pname = "plasma-settings"; + + nativeBuildInputs = [ + cmake + extra-cmake-modules + ]; + + buildInputs = [ + kauth + kconfig + kcoreaddons + kdbusaddons + ki18n + kitemmodels + plasma-framework + ]; + + meta = with lib; { + description = "Settings application for Plasma Mobile"; + homepage = "https://invent.kde.org/plasma-mobile/plasma-settings"; + # https://invent.kde.org/plasma-mobile/plasma-settings/-/commit/a59007f383308503e59498b3036e1483bca26e35 + license = licenses.gpl2Plus; + maintainers = with maintainers; [ samueldr ]; + }; +} diff --git a/pkgs/desktops/plasma-5/default.nix b/pkgs/desktops/plasma-5/default.nix index 8abf2b37dbeca..dd3634ac7cd3e 100644 --- a/pkgs/desktops/plasma-5/default.nix +++ b/pkgs/desktops/plasma-5/default.nix @@ -134,9 +134,11 @@ let milou = callPackage ./milou.nix {}; oxygen = callPackage ./oxygen.nix {}; plasma-browser-integration = callPackage ./plasma-browser-integration.nix {}; + plasma-phone-components = callPackage ./plasma-phone-components {}; plasma-desktop = callPackage ./plasma-desktop {}; plasma-disks = callPackage ./plasma-disks.nix {}; plasma-integration = callPackage ./plasma-integration {}; + plasma-nano = callPackage ./plasma-nano {}; plasma-nm = callPackage ./plasma-nm {}; plasma-pa = callPackage ./plasma-pa.nix { inherit gconf; }; plasma-sdk = callPackage ./plasma-sdk.nix {}; diff --git a/pkgs/desktops/plasma-5/plasma-nano/default.nix b/pkgs/desktops/plasma-5/plasma-nano/default.nix new file mode 100644 index 0000000000000..0960eec33f2d8 --- /dev/null +++ b/pkgs/desktops/plasma-5/plasma-nano/default.nix @@ -0,0 +1,13 @@ +{ + mkDerivation, + extra-cmake-modules, + plasma-framework +}: + +mkDerivation { + name = "plasma-nano"; + nativeBuildInputs = [ extra-cmake-modules ]; + buildInputs = [ + plasma-framework + ]; +} diff --git a/pkgs/desktops/plasma-5/plasma-phone-components/default.nix b/pkgs/desktops/plasma-5/plasma-phone-components/default.nix new file mode 100644 index 0000000000000..d925d7e408b51 --- /dev/null +++ b/pkgs/desktops/plasma-5/plasma-phone-components/default.nix @@ -0,0 +1,43 @@ +{ + mkDerivation, lib, + + extra-cmake-modules, kdoctools, + + coreutils, dbus, gnugrep, gnused, libdbusmenu, pam, wayland, appstream, + + kdeclarative, kdelibs4support, kpeople, kconfig, krunner, kinit, kwayland, kwin, + plasma-framework, telepathy, libphonenumber, protobuf, libqofono, modemmanager-qt, + plasma-workspace, + maliit-framework, maliit-keyboard, + + qtwayland, qttools +}: + +let inherit (lib) getBin getLib; in + +mkDerivation { + name = "plasma-phone-components"; + + nativeBuildInputs = [ extra-cmake-modules kdoctools ]; + buildInputs = [ + appstream libdbusmenu pam wayland + kdeclarative kdelibs4support kpeople kconfig krunner kinit kwayland kwin + plasma-framework telepathy libphonenumber protobuf libqofono modemmanager-qt + maliit-framework maliit-keyboard + ]; + + postPatch = '' + substituteInPlace bin/kwinwrapper.in \ + --replace @KDE_INSTALL_FULL_LIBEXECDIR@ "${plasma-workspace}/libexec" + + substituteInPlace bin/plasma-mobile.desktop.cmake \ + --replace @CMAKE_INSTALL_FULL_LIBEXECDIR@ "${plasma-workspace}/libexec" + ''; + + # Ensures dependencies like libqofono (at the very least) are present for the shell. + preFixup = '' + wrapQtApp "$out/bin/kwinwrapper" + ''; + + passthru.providedSessions = [ "plasma-mobile" ]; +} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 946326d1979d6..89bf40c5887fd 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1217,6 +1217,8 @@ mapAliases ({ qqc2-breeze-style sddm-kcm systemsettings xdg-desktop-portal-kde + plasma-phone-components + plasma-nano ; inherit (plasma5Packages.thirdParty) plasma-applet-caffeine-plus diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 8a226e7cc3462..d3c111e2e86d8 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3292,6 +3292,10 @@ with pkgs; maigret = callPackage ../tools/security/maigret { }; + maliit-framework = libsForQt5.callPackage ../applications/misc/maliit-framework { }; + + maliit-keyboard = libsForQt5.callPackage ../applications/misc/maliit-keyboard { }; + mapcidr = callPackage ../tools/misc/mapcidr { }; mapproxy = callPackage ../applications/misc/mapproxy { };