Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/plasma: use upstream xsession/wayland files #100057

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

@pasqui23
Copy link
Contributor

@pasqui23 pasqui23 commented Oct 8, 2020

Motivation for this change

An updated version of #56988
Wayland still does not work and ~/.local/share/sddm/wayland-session.log is empty after a failed Wayland login,as journalctl -u display-manager.

I will fix the override after making Wayland work

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
@worldofpeace worldofpeace added this to the 21.03 milestone Oct 9, 2020
start = startplasma;
};
services.xserver.displayManager.sessionPackages = [ (plasma5.plasma-workspace.overrideAttrs(old:{
passthru.providedSessions=["plasma" "plasmawayland"];
Copy link
Contributor

@worldofpeace worldofpeace Oct 9, 2020

I think you can just add this to plasma-workspace, or does libsForQt5.mkDerivation make it so you cant?

Copy link
Contributor Author

@pasqui23 pasqui23 Oct 9, 2020

I will,after making it work on wayland

environment.systemPackages =
with qt5; with libsForQt5;
with plasma5; with kdeApplications; with kdeFrameworks;
environment.systemPackages = with pkgs; with qt5; with libsForQt5; with plasma5; with kdeApplications;
Copy link
Contributor

@worldofpeace worldofpeace Oct 9, 2020

this looks like something from the rebase. please revert

@@ -274,7 +268,6 @@ in
plasma-browser-integration
plasma-integration
polkit-kde-agent
spectacle
Copy link
Contributor

@worldofpeace worldofpeace Oct 9, 2020

@@ -298,21 +291,21 @@ in

qtvirtualkeyboard

pkgs.xdg-user-dirs # Update user dirs as described in https://freedesktop.org/wiki/Software/xdg-user-dirs/
]

# Phonon audio backend
++ lib.optional (cfg.phononBackend == "gstreamer") libsForQt5.phonon-backend-gstreamer
++ lib.optional (cfg.phononBackend == "vlc") libsForQt5.phonon-backend-vlc

# Optional hardware support features
++ lib.optionals config.hardware.bluetooth.enable [ bluedevil bluez-qt pkgs.openobex pkgs.obexftp ]
++ lib.optionals config.hardware.bluetooth.enable [ bluedevil bluez-qt openobex obexftp ]
++ lib.optional config.networking.networkmanager.enable plasma-nm
++ lib.optional config.hardware.pulseaudio.enable plasma-pa
++ lib.optional config.powerManagement.enable powerdevil
++ lib.optional config.services.colord.enable pkgs.colord-kde
++ lib.optional config.services.colord.enable colord-kde
++ lib.optionals config.services.samba.enable [ kdenetwork-filesharing pkgs.samba ]
++ lib.optional config.services.xserver.wacom.enable pkgs.wacomtablet;
++ lib.optional config.services.xserver.wacom.enable wacomtablet;
@@ -326,7 +319,7 @@ in

fonts.fonts = with pkgs; [ noto-fonts hack-font ];
fonts.fontconfig.defaultFonts = {
monospace = [ "Hack" "Noto Sans Mono" ];
monospace = [ "Hack" "Noto Mono" ];
@@ -363,7 +356,7 @@ in

# Update the start menu for each user that is currently logged in
system.userActivationScripts.plasmaSetup = activationScript;

Copy link
Contributor

@worldofpeace worldofpeace Oct 9, 2020

trailing whitespace

inherit (pkgs) kdeApplications kdeFrameworks plasma5;
libsForQt5 = pkgs.libsForQt514;
qt5 = pkgs.qt514;
inherit (pkgs) kdeApplications plasma5 libsForQt5 qt5;
Copy link
Contributor

@worldofpeace worldofpeace Oct 9, 2020

this being qt514 is intentional. guessing rebase artifact

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Oct 12, 2020

So the wayland session still quit on startup,but now it does not seem to leave any traces,whether in the journal nor in ~/.local/share/sddm/wayland-session.log `.

@worldofpeace any ideas why?

@hameerabbasi
Copy link

@hameerabbasi hameerabbasi commented Oct 20, 2020

Maybe the description of #44139 will help?

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Oct 20, 2020

The wayland entry is present in sddm,but does not work.
Still ,I need to check with QT_DEBUG_PLUGINS=1;QML_IMPORT_TRACE=1;

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Oct 20, 2020

Also need to check for wrapQtApps

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Oct 26, 2020

@hameerabbasi Checked with the suggested patch,still not working,got in .local/share/sddm/wayland-session.log ;

dbus-daemon[16640]: [session uid=1001 pid=16640] Activating service name='org.freedesktop.systemd1' requested by ':1.0' (uid=1001 pid=16644 comm="/nix/store/90n7mvl7n0zl98wx0jjx2syfma34xhka-dbus-1" label="kernel")
dbus-daemon[16640]: [session uid=1001 pid=16640] Activated service 'org.freedesktop.systemd1' failed: Process org.freedesktop.systemd1 exited with status 1
dbus-update-activation-environment: warning: error sending to systemd: org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.freedesktop.systemd1 exited with status 1
qt.qpa.plugin: Could not load the Qt platform plugin "wayland-org.kde.kwin.qpa" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: wayland-org.kde.kwin.qpa, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, xcb.

"/nix/store/bkdyka5fa5f707a6hvx8l6v2s37wvwvd-kwin-5.18.5-bin/bin/kwin_wayland" ("--xwayland", "--libinput", "--exit-with-session=/nix/store/2vqimab57z8f8cpbzkax9cwnb1rl997j-plasma-workspace-5.18.5/libexec/startplasma-waylandsession") exited with code 6
startplasmacompositor: Shutting down...
startplasmacompositor: Done.

@matklad
Copy link
Member

@matklad matklad commented Oct 28, 2020

@pasqui23 see #43757 (comment)

Specifically, env KWIN_FORCE_OWN_QPA=1 kwin_wayland --version fixes this particular error for me.

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Oct 29, 2020

@matklad adding said variable to environment.sessionVariables still does not fix it for me

@poscat0x04 poscat0x04 mentioned this pull request Nov 1, 2020
10 tasks
@CertainLach
Copy link
Contributor

@CertainLach CertainLach commented Dec 22, 2020

Adding KWIN_FORCE_OWN_QPA=1 and increasing limit (0004-start_kdeinit-environ-hard-limit.patch) to 1<<20 makes startplasma_wayland work for me

See #107472 #107476

@CertainLach
Copy link
Contributor

@CertainLach CertainLach commented Dec 25, 2020

For anyone wondering: plasma on wayland is not quite stable on NixOS, screenshots can't be taken because of X-KDE-DBUS-Restricted-Interfaces attribute absence, and plasmashell has some bugs (Task manager shows no apps) because of missing X-KDE-Wayland-Interfaces

Kwin even can't find desktop files for anything, because of wrappers?

KWIN_UTILS: Could not find the desktop file for "/nix/store/v24qakxc15pnj60i7ydqzsd9svdjdjp6-plasma-workspace-5.20.4/bin/.plasmashell-wrapped"
KWIN_UTILS: Could not find the desktop file for "/nix/store/0kbrkb257806lgx5q46gw59scgd2vhqm-yakuake/bin/.yakuake-wrapped"
KWIN_UTILS: Could not find the desktop file for "/nix/store/rabb2qzn14fvq4ksvd063fwcj6d9hwq8-spectacle/bin/.spectacle-wrapped"

See #107595

@oxalica
Copy link
Contributor

@oxalica oxalica commented Mar 20, 2021

After #110536, the analog/digital clock widgets got broken on (only) wayland. 😢
Note that time of analog clock is incorrect and fixed. The digital clock is below the analog clock and it shows nothing.
Screenshot_20210321_021850

@peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Mar 22, 2021

Guys, I'm spamming some of the old KDE wayland issues/PRs to ensure we get some testers. This comment is written from a plasma wayland session spawned from sddm after applying this PR (and the one-liner mentioned in a comment) which basically gets it going: #117102

@samueldr
Copy link
Member

@samueldr samueldr commented Mar 22, 2021

@peterhoeg which one-liner?

And you didn't hit anything not working without #116549?

@peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Mar 22, 2021

@peterhoeg which one-liner?

I have updated the PR's first post with all the details, but basically you just need to point sddm at the directory with the wayland sessions:

services.xserver.displayManager.sddm.settings.Wayland.SessionDir =
  "${pkgs.plasma5Packages.plasma-workspace}/share/wayland-sessions";

And you didn't hit anything not working without #116549?

The pager doesn't show icons for the running applications but otherwise no, not
really. It's not possible for me to use as a daily driver though until I sort out the
custom keyboard mappings, but that's not Plasma's fault.

@peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Mar 22, 2021

@samueldr , reading your linked PR, I'm guessing this is why the pager/task manager do not show any icons.

@peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Mar 23, 2021

@samueldr - with your PR the task manager/pager both work! hidpi support is still horrible so I can't really try it out until I'm on a desktop again.

@peterhoeg
Copy link
Member

@peterhoeg peterhoeg commented Mar 24, 2021

@pasqui23, when using systemd to manage the session (necessary patches are in master but haven't hit unstable yet), I can use the upstream sessions for both x11 and wayland without modification:

services.xserver.displayManager.sddm.settings.X11.SessionDir =
  "${pkgs.plasma5Packages.plasma-workspace}/share/xsessions";

services.xserver.displayManager.sddm.settings.Wayland.SessionDir =
  "${pkgs.plasma5Packages.plasma-workspace}/share/wayland-sessions";

This is admittedly only tried out with a user that already has everything set up, so I don't know if things will break without all the setup handled by our currect launcher script. That just needs to be tested.

But this got me thinking. Now that both GNOME and KDE use systemd, we could also start running these various scripts through systemd which of course also allows to share them in a cleaner way.

First we ensure that plasma uses systemd:

systemd.user.services = {
  plasma-run-with-systemd = {
    description = "Run via systemd";
    wantedBy = [ "basic.target" ];
    environment.XDG_CONFIG_HOME = "$HOME/.config";
    serviceConfig.Type = "oneshot";
    script = ''
      set -eEuo pipefail

      # use systemd to manage the session
      echo -e "[General]\nsystemdBoot=true" > $XDG_CONFIG_HOME/startkderc
    '';
  };

Then we run what is currently handled in our session wrapper script:

  plasma-early-setup = {
    description = "Early Plasma setup";
    wantedBy = [ "graphical-session-pre.target" ];
    environment = {
      XDG_CACHE_HOME = "$HOME/.cache";
      XDG_CONFIG_HOME = "$HOME/.config";
    };
    serviceConfig.Type = "oneshot";
    script = ''
      set -eEuo pipefail

      # The KDE icon cache is supposed to update itself automatically, but it uses
      # the timestamp on the icon theme directory as a trigger. This doesn't work
      # on NixOS because the timestamp never changes. As a workaround, delete the
      # icon cache at login and session activation.
      # See also: http://lists-archives.org/kde-devel/26175-what-when-will-icon-cache-refresh.html
      rm -fv $XDG_CACHE_HOME/icon-cache.kcache

      # xdg-desktop-settings generates this empty file but
      # it makes kbuildsyscoca5 fail silently. To fix this
      # remove that menu if it exists.
      rm -fv ''${XDG_CONFIG_HOME}/menus/applications-merged/xdg-desktop-menu-dummy.menu

      # 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.
      trolltech_conf="''${XDG_CONFIG_HOME}/Trolltech.conf"
      if [ -e "$trolltech_conf" ]; then
        ${pkgs.gnused}/bin/sed -i "$trolltech_conf" -e '/nix\\store\|nix\/store/ d'
      fi

      # Remove the kbuildsyscoca5 cache. It will be regenerated
      # immediately after. This is necessary for kbuildsyscoca5 to
      # recognize that software that has been removed.
      rm -fv $XDG_CACHE_HOME/ksycoca*

    ${pkgs.plasma5Packages.kservice}/bin/kbuildsycoca5
    '';
  };
};

Something like the trolltech.conf patching could also be split into a separate
unit as it applies to all environments in which people could possibly run qt
applications. So one way to deal with this would be to define a
graphical-early-setup.service for generic stuff and
plasma-early-setup.service, gnome-early-setup.service, etc.

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Apr 3, 2021

@peterhoeg please add this issue to the wayland project

@peterhoeg peterhoeg added this to KDE/Qt specific in Wayland Apr 6, 2021
@jansol
Copy link
Contributor

@jansol jansol commented Sep 16, 2021

This could use a rebase

@@ -39,6 +39,11 @@
(<link xlink:href="https://github.com/NixOS/nixpkgs/issues/75478">#7547</link>).
</para>
</listitem>
<listitem>
Copy link
Member

@SuperSandro2000 SuperSandro2000 Sep 16, 2021

Where are the changes in the md file?

@@ -183,18 +179,15 @@ in

config = mkMerge [
(mkIf cfg.enable {

Copy link
Member

@SuperSandro2000 SuperSandro2000 Sep 16, 2021

Please revert.

@@ -91,6 +96,12 @@
</para>

<itemizedlist>
<listitem>
<para>
The X11 Plasma session name is now <literal>plasma</literal>, not <literal>plasma5</literal>.
Copy link
Member

@SuperSandro2000 SuperSandro2000 Sep 16, 2021

Please add in code the rename so that people with aliases enabled don't need to do anything.

@pasqui23
Copy link
Contributor Author

@pasqui23 pasqui23 commented Sep 17, 2021

@SuperSandro2000 rebased this branch onto master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment