element-desktop: use native wayland, not Xwayland

This commit is contained in:
2024-03-23 18:51:41 +00:00
parent 6646a21089
commit f16a68f5bb

View File

@@ -4,16 +4,25 @@
# - <https://github.com/vector-im/element-desktop/issues/1029#issuecomment-1632688224>
# - `rm -rf ~/.config/Element/GPUCache`
# - <https://github.com/NixOS/nixpkgs/issues/244486>
{ 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"