From f16a68f5bbc8122fbc4711031677f801d897462c Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 23 Mar 2024 18:51:41 +0000 Subject: [PATCH] element-desktop: use native wayland, not Xwayland --- hosts/common/programs/element-desktop.nix | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/hosts/common/programs/element-desktop.nix b/hosts/common/programs/element-desktop.nix index 002d92e55..a12dfb195 100644 --- a/hosts/common/programs/element-desktop.nix +++ b/hosts/common/programs/element-desktop.nix @@ -4,16 +4,25 @@ # - # - `rm -rf ~/.config/Element/GPUCache` # - -{ pkgs, ... }: +{ lib, pkgs, ... }: { sane.programs.element-desktop = { - packageUnwrapped = pkgs.element-desktop.override { + packageUnwrapped = (pkgs.element-desktop.override { # use pre-built electron because otherwise it takes 4 hrs to build from source. electron = pkgs.electron_28-bin; - }; + }).overrideAttrs (upstream: { + # fix to use wayland instead of Xwayland: + # - replace `NIXOS_OZONE_WL` non-empty check with `WAYLAND_DISPLAY` + # - use `wayland` instead of `auto` because --ozone-platform-hint=auto still prefers X over wayland when both are available + # alternatively, set env var: `ELECTRON_OZONE_PLATFORM_HINT=wayland` and ignore all of this + installPhase = lib.replaceStrings + [ "NIXOS_OZONE_WL" "--ozone-platform-hint=auto" ] + [ "WAYLAND_DISPLAY" "--ozone-platform-hint=wayland" ] + upstream.installPhase + ; + }); suggestedPrograms = [ "gnome-keyring" - "xwayland" ]; sandbox.method = "bwrap"; @@ -22,7 +31,6 @@ sandbox.whitelistDbus = [ "user" ]; # notifications sandbox.whitelistDri = true; sandbox.whitelistWayland = true; - sandbox.whitelistX = true; sandbox.extraHomePaths = [ "Music" "Pictures/albums"