I want to add an environment variable to a systemd user service to get more verbose logs from it, KDE Plasma Powerdevil in particular.
To do so I added the following to my config:
systemd.user.services.plasma-powerdevil.environment = {
QT_LOGGING_RULES = "org.kde.powerdevil=true";
};
I would expect this to add that environment variable to the service, leaving everything else untouched. However, it replaces the service entirely making it not work anymore.
Before the service file looked as follows:
[Unit]
Description=Powerdevil
PartOf=graphical-session.target
After=plasma-core.target
[Service]
ExecStart=/nix/store/bagdjv9pazhybd5kf7lxdh1d0igmdhd0-powerdevil-6.2.5/libexec/org_kde_powerdevil
Type=dbus
BusName=org.kde.Solid.PowerManagement
TimeoutStopSec=5sec
Slice=background.slice
Restart=on-failure
after adding the option:
[Unit]
[Service]
Environment="LOCALE_ARCHIVE=/nix/store/z3zx69xr38jlrv875ld0i0c11njfflzi-glibc-locales-2.40-66/lib/locale/locale-archive"
Environment="PATH=/nix/store/9m68vvhnsq5cpkskphgw84ikl9m6wjwp-coreutils-9.5/bin:/nix/store/vc2d1bfy1a5y1195nq7k6p0zcm6q89nx-findutils-4.10.0/bin:/nix/store/qjsj5vnbfpbg6r7jhd7znfgmcy0arn8n-gnugrep-3.11/bin:/nix/store/3ks7b6p43dpvnlnxgvlcy2jaf1np37p2-gnused-4.9/bin:/nix/store/w9qcpyhjrxsqrps91wkz8r4mqvg9zrxc-systemd-256.10/bin:/nix/store/9m68vvhnsq5cpkskphgw84ikl9m6wjwp-coreuti>
Environment="QT_LOGGING_RULES=org.kde.powerdevil=true"
Environment="TZDIR=/nix/store/l6mypzy4rvkxd5kwzs18d88syirislib-tzdata-2024b/share/zoneinfo"
How can I add en environment variable to a user service without changing anything else?