Skip to content

Commit

Permalink
Merge pull request #121345 from samueldr/feature/plasma-mobile
Browse files Browse the repository at this point in the history
Add support for Plasma Mobile
  • Loading branch information
samueldr authored Dec 4, 2021
2 parents f191650 + 2f12f30 commit b976947
Show file tree
Hide file tree
Showing 10 changed files with 451 additions and 39 deletions.
233 changes: 194 additions & 39 deletions nixos/modules/services/x11/desktop-managers/plasma5.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = [
Expand All @@ -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 = {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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" ];
Expand All @@ -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 ];
})
];
}
68 changes: 68 additions & 0 deletions pkgs/applications/misc/maliit-framework/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
Loading

0 comments on commit b976947

Please sign in to comment.