nixos/plasma5: make running with systemd configurable
parent
718895c149
commit
f1a82a2182
|
@ -1,15 +1,18 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
xcfg = config.services.xserver;
|
xcfg = config.services.xserver;
|
||||||
cfg = xcfg.desktopManager.plasma5;
|
cfg = xcfg.desktopManager.plasma5;
|
||||||
|
|
||||||
libsForQt5 = pkgs.plasma5Packages;
|
libsForQt5 = pkgs.plasma5Packages;
|
||||||
inherit (libsForQt5) kdeGear kdeFrameworks plasma5;
|
inherit (libsForQt5) kdeGear kdeFrameworks plasma5;
|
||||||
inherit (pkgs) writeText;
|
inherit (pkgs) writeText;
|
||||||
|
inherit (lib)
|
||||||
|
getBin optionalString
|
||||||
|
mkRemovedOptionModule mkRenamedOptionModule
|
||||||
|
mkDefault mkIf mkMerge mkOption types;
|
||||||
|
|
||||||
|
ini = pkgs.formats.ini { };
|
||||||
|
|
||||||
pulseaudio = config.hardware.pulseaudio;
|
pulseaudio = config.hardware.pulseaudio;
|
||||||
pactl = "${getBin pulseaudio.package}/bin/pactl";
|
pactl = "${getBin pulseaudio.package}/bin/pactl";
|
||||||
|
@ -33,23 +36,25 @@ let
|
||||||
gtk-button-images=1
|
gtk-button-images=1
|
||||||
'';
|
'';
|
||||||
|
|
||||||
gtk3_settings = writeText "settings.ini" ''
|
gtk3_settings = ini.generate "settings.ini" {
|
||||||
[Settings]
|
Settings = {
|
||||||
gtk-font-name=Sans Serif Regular 10
|
gtk-font-name = "Sans Serif Regular 10";
|
||||||
gtk-theme-name=Breeze
|
gtk-theme-name = "Breeze";
|
||||||
gtk-icon-theme-name=breeze
|
gtk-icon-theme-name = "breeze";
|
||||||
gtk-fallback-icon-theme=hicolor
|
gtk-fallback-icon-theme = "hicolor";
|
||||||
gtk-cursor-theme-name=breeze_cursors
|
gtk-cursor-theme-name = "breeze_cursors";
|
||||||
gtk-toolbar-style=GTK_TOOLBAR_ICONS
|
gtk-toolbar-style = "GTK_TOOLBAR_ICONS";
|
||||||
gtk-menu-images=1
|
gtk-menu-images = 1;
|
||||||
gtk-button-images=1
|
gtk-button-images = 1;
|
||||||
'';
|
};
|
||||||
|
};
|
||||||
|
|
||||||
kcminputrc = writeText "kcminputrc" ''
|
kcminputrc = ini.generate "kcminputrc" {
|
||||||
[Mouse]
|
Mouse = {
|
||||||
cursorTheme=breeze_cursors
|
cursorTheme = "breeze_cursors";
|
||||||
cursorSize=0
|
cursorSize = 0;
|
||||||
'';
|
};
|
||||||
|
};
|
||||||
|
|
||||||
activationScript = ''
|
activationScript = ''
|
||||||
${set_XDG_CONFIG_HOME}
|
${set_XDG_CONFIG_HOME}
|
||||||
|
@ -87,13 +92,13 @@ let
|
||||||
'';
|
'';
|
||||||
|
|
||||||
set_XDG_CONFIG_HOME = ''
|
set_XDG_CONFIG_HOME = ''
|
||||||
# Set the default XDG_CONFIG_HOME if it is unset.
|
# Set the default XDG_CONFIG_HOME if it is unset.
|
||||||
# Per the XDG Base Directory Specification:
|
# Per the XDG Base Directory Specification:
|
||||||
# https://specifications.freedesktop.org/basedir-spec/latest
|
# https://specifications.freedesktop.org/basedir-spec/latest
|
||||||
# 1. Never export this variable! If it is unset, then child processes are
|
# 1. Never export this variable! If it is unset, then child processes are
|
||||||
# expected to set the default themselves.
|
# expected to set the default themselves.
|
||||||
# 2. Contaminate / if $HOME is unset; do not check if $HOME is set.
|
# 2. Contaminate / if $HOME is unset; do not check if $HOME is set.
|
||||||
XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-$HOME/.config}
|
XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-$HOME/.config}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
startplasma =
|
startplasma =
|
||||||
|
@ -116,20 +121,17 @@ let
|
||||||
if ! [ -f "$kdeglobals" ]
|
if ! [ -f "$kdeglobals" ]
|
||||||
then
|
then
|
||||||
kcminputrc="''${XDG_CONFIG_HOME}/kcminputrc"
|
kcminputrc="''${XDG_CONFIG_HOME}/kcminputrc"
|
||||||
if ! [ -f "$kcminputrc" ]
|
if ! [ -f "$kcminputrc" ]; then
|
||||||
then
|
|
||||||
cat ${kcminputrc} >"$kcminputrc"
|
cat ${kcminputrc} >"$kcminputrc"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gtkrc2="$HOME/.gtkrc-2.0"
|
gtkrc2="$HOME/.gtkrc-2.0"
|
||||||
if ! [ -f "$gtkrc2" ]
|
if ! [ -f "$gtkrc2" ]; then
|
||||||
then
|
|
||||||
cat ${gtkrc2} >"$gtkrc2"
|
cat ${gtkrc2} >"$gtkrc2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
gtk3_settings="''${XDG_CONFIG_HOME}/gtk-3.0/settings.ini"
|
gtk3_settings="''${XDG_CONFIG_HOME}/gtk-3.0/settings.ini"
|
||||||
if ! [ -f "$gtk3_settings" ]
|
if ! [ -f "$gtk3_settings" ]; then
|
||||||
then
|
|
||||||
mkdir -p "$(dirname "$gtk3_settings")"
|
mkdir -p "$(dirname "$gtk3_settings")"
|
||||||
cat ${gtk3_settings} >"$gtk3_settings"
|
cat ${gtk3_settings} >"$gtk3_settings"
|
||||||
fi
|
fi
|
||||||
|
@ -140,42 +142,44 @@ let
|
||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
options = {
|
options.services.xserver.desktopManager.plasma5 = {
|
||||||
|
enable = mkOption {
|
||||||
services.xserver.desktopManager.plasma5 = {
|
type = types.bool;
|
||||||
enable = mkOption {
|
default = false;
|
||||||
type = types.bool;
|
description = "Enable the Plasma 5 (KDE 5) desktop environment.";
|
||||||
default = false;
|
|
||||||
description = "Enable the Plasma 5 (KDE 5) desktop environment.";
|
|
||||||
};
|
|
||||||
|
|
||||||
phononBackend = mkOption {
|
|
||||||
type = types.enum [ "gstreamer" "vlc" ];
|
|
||||||
default = "gstreamer";
|
|
||||||
example = "vlc";
|
|
||||||
description = "Phonon audio backend to install.";
|
|
||||||
};
|
|
||||||
|
|
||||||
supportDDC = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = ''
|
|
||||||
Support setting monitor brightness via DDC.
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
This is not needed for controlling brightness of the internal monitor
|
|
||||||
of a laptop and as it is considered experimental by upstream, it is
|
|
||||||
disabled by default.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
useQtScaling = mkOption {
|
|
||||||
type = types.bool;
|
|
||||||
default = false;
|
|
||||||
description = "Enable HiDPI scaling in Qt.";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
phononBackend = mkOption {
|
||||||
|
type = types.enum [ "gstreamer" "vlc" ];
|
||||||
|
default = "gstreamer";
|
||||||
|
example = "vlc";
|
||||||
|
description = "Phonon audio backend to install.";
|
||||||
|
};
|
||||||
|
|
||||||
|
supportDDC = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Support setting monitor brightness via DDC.
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
This is not needed for controlling brightness of the internal monitor
|
||||||
|
of a laptop and as it is considered experimental by upstream, it is
|
||||||
|
disabled by default.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
useQtScaling = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = "Enable HiDPI scaling in Qt.";
|
||||||
|
};
|
||||||
|
|
||||||
|
runUsingSystemd = mkOption {
|
||||||
|
description = "Use systemd to manage the Plasma session";
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
imports = [
|
imports = [
|
||||||
|
@ -187,32 +191,37 @@ in
|
||||||
(mkIf cfg.enable {
|
(mkIf cfg.enable {
|
||||||
|
|
||||||
# Seed our configuration into nixos-generate-config
|
# Seed our configuration into nixos-generate-config
|
||||||
system.nixos-generate-config.desktopConfiguration = [''
|
system.nixos-generate-config.desktopConfiguration = [
|
||||||
# Enable the Plasma 5 Desktop Environment.
|
''
|
||||||
services.xserver.displayManager.sddm.enable = true;
|
# Enable the Plasma 5 Desktop Environment.
|
||||||
services.xserver.desktopManager.plasma5.enable = true;
|
services.xserver.displayManager.sddm.enable = true;
|
||||||
''];
|
services.xserver.desktopManager.plasma5.enable = true;
|
||||||
|
''
|
||||||
|
];
|
||||||
|
|
||||||
services.xserver.displayManager.sessionPackages = [ pkgs.libsForQt5.plasma5.plasma-workspace ];
|
services.xserver.displayManager.sessionPackages = [ pkgs.libsForQt5.plasma5.plasma-workspace ];
|
||||||
|
|
||||||
security.wrappers = {
|
security.wrappers = {
|
||||||
kcheckpass =
|
kcheckpass =
|
||||||
{ setuid = true;
|
{
|
||||||
|
setuid = true;
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
source = "${lib.getBin libsForQt5.kscreenlocker}/libexec/kcheckpass";
|
source = "${getBin libsForQt5.kscreenlocker}/libexec/kcheckpass";
|
||||||
};
|
};
|
||||||
start_kdeinit =
|
start_kdeinit =
|
||||||
{ setuid = true;
|
{
|
||||||
|
setuid = true;
|
||||||
owner = "root";
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
source = "${lib.getBin libsForQt5.kinit}/libexec/kf5/start_kdeinit";
|
source = "${getBin libsForQt5.kinit}/libexec/kf5/start_kdeinit";
|
||||||
};
|
};
|
||||||
kwin_wayland =
|
kwin_wayland =
|
||||||
{ owner = "root";
|
{
|
||||||
|
owner = "root";
|
||||||
group = "root";
|
group = "root";
|
||||||
capabilities = "cap_sys_nice+ep";
|
capabilities = "cap_sys_nice+ep";
|
||||||
source = "${lib.getBin plasma5.kwin}/bin/kwin_wayland";
|
source = "${getBin plasma5.kwin}/bin/kwin_wayland";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -247,7 +256,7 @@ in
|
||||||
kidletime
|
kidletime
|
||||||
kimageformats
|
kimageformats
|
||||||
kinit
|
kinit
|
||||||
kirigami2 # In system profile for SDDM theme. TODO: wrapper.
|
kirigami2 # In system profile for SDDM theme. TODO: wrapper.
|
||||||
kio
|
kio
|
||||||
kjobwidgets
|
kjobwidgets
|
||||||
knewstuff
|
knewstuff
|
||||||
|
@ -314,7 +323,8 @@ in
|
||||||
breeze-icons
|
breeze-icons
|
||||||
pkgs.hicolor-icon-theme
|
pkgs.hicolor-icon-theme
|
||||||
|
|
||||||
kde-gtk-config breeze-gtk
|
kde-gtk-config
|
||||||
|
breeze-gtk
|
||||||
|
|
||||||
qtvirtualkeyboard
|
qtvirtualkeyboard
|
||||||
|
|
||||||
|
@ -385,6 +395,27 @@ in
|
||||||
security.pam.services.lightdm.enableKwallet = true;
|
security.pam.services.lightdm.enableKwallet = true;
|
||||||
security.pam.services.sddm.enableKwallet = true;
|
security.pam.services.sddm.enableKwallet = true;
|
||||||
|
|
||||||
|
systemd.user.services = {
|
||||||
|
plasma-early-setup = mkIf cfg.runUsingSystemd {
|
||||||
|
description = "Early Plasma setup";
|
||||||
|
wantedBy = [ "graphical-session-pre.target" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = activationScript;
|
||||||
|
};
|
||||||
|
|
||||||
|
plasma-run-with-systemd = {
|
||||||
|
description = "Run KDE Plasma via systemd";
|
||||||
|
wantedBy = [ "basic.target" ];
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = ''
|
||||||
|
${set_XDG_CONFIG_HOME}
|
||||||
|
|
||||||
|
${kdeFrameworks.kconfig}/bin/kwriteconfig5 \
|
||||||
|
--file startkderc --group General --key systemdBoot ${lib.boolToString cfg.runUsingSystemd}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
xdg.portal.enable = true;
|
xdg.portal.enable = true;
|
||||||
xdg.portal.extraPortals = [ plasma5.xdg-desktop-portal-kde ];
|
xdg.portal.extraPortals = [ plasma5.xdg-desktop-portal-kde ];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue