From d1de9efde133c0c36bced5aa2cf4c53d6f9f875f Mon Sep 17 00:00:00 2001 From: Colin Date: Wed, 21 Feb 2024 23:32:10 +0000 Subject: [PATCH] sway: port xwayland use to sane.programs API --- hosts/common/programs/element-desktop.nix | 16 +++++++++------- hosts/common/programs/sway/default.nix | 22 ++++++++-------------- hosts/common/programs/sway/sway-config.nix | 2 +- hosts/modules/gui/sxmo/default.nix | 6 ------ 4 files changed, 18 insertions(+), 28 deletions(-) diff --git a/hosts/common/programs/element-desktop.nix b/hosts/common/programs/element-desktop.nix index 2dcb64ef..fb1f518a 100644 --- a/hosts/common/programs/element-desktop.nix +++ b/hosts/common/programs/element-desktop.nix @@ -7,6 +7,15 @@ { pkgs, ... }: { sane.programs.element-desktop = { + packageUnwrapped = pkgs.element-desktop.override { + # use pre-build electron because otherwise it takes 4 hrs to build from source. + electron = pkgs.electron-bin; + }; + suggestedPrograms = [ + "gnome-keyring" + "xwayland" + ]; + sandbox.method = "bwrap"; sandbox.wrapperType = "wrappedDerivation"; sandbox.net = "clearnet"; @@ -23,14 +32,7 @@ "tmp" ]; - packageUnwrapped = pkgs.element-desktop.override { - # use pre-build electron because otherwise it takes 4 hrs to build from source. - electron = pkgs.electron-bin; - }; - # creds/session keys, etc persist.byStore.private = [ ".config/Element" ]; - - suggestedPrograms = [ "gnome-keyring" ]; }; } diff --git a/hosts/common/programs/sway/default.nix b/hosts/common/programs/sway/default.nix index fc5be9f0..2e824b5c 100644 --- a/hosts/common/programs/sway/default.nix +++ b/hosts/common/programs/sway/default.nix @@ -29,9 +29,16 @@ let }; swayPackage = wrapSway (pkgs.sway-unwrapped.overrideAttrs (_: { # isNixOS = true; #< doesn't matter + # + # about xwayland: + # - required by many electron apps, though some electron apps support NIXOS_OZONE_WL=1 for native wayland. + # - when xwayland is enabled, KOreader incorrectly chooses the X11 backend + # -> slower; blurrier + # - xwayland uses a small amount of memory (like 30MiB, IIRC?) + # # TODO: something else is dragging a xwayland-enabled wlroots into the environment, # making this actually kinda wasteful. - enableXWayland = cfg.config.xwayland; + enableXWayland = config.sane.programs.xwayland.enabled; })); in { @@ -81,14 +88,6 @@ in - etc ''; }; - xwayland = mkOption { - type = types.bool; - default = true; - description = '' - whether or not to enable xwayland (allows running X11 apps on sway). - some electron apps (e.g. element-desktop) require xwayland. - ''; - }; screenshot_cmd = mkOption { type = types.str; @@ -199,11 +198,6 @@ in # icon-theme = lib.mkDefault "Flat-Remix-Grey-Light"; # requires qtbase }; - # TODO: port to sane.programs - programs.xwayland = lib.mkIf cfg.enabled { - enable = cfg.config.xwayland; - }; - services.gvfs = lib.mkIf cfg.enabled { enable = true; # allow nautilus to mount remote filesystems (e.g. ftp://...) package = lib.mkDefault (pkgs.gvfs.override { diff --git a/hosts/common/programs/sway/sway-config.nix b/hosts/common/programs/sway/sway-config.nix index e7a987c9..d23fb953 100644 --- a/hosts/common/programs/sway/sway-config.nix +++ b/hosts/common/programs/sway/sway-config.nix @@ -35,5 +35,5 @@ in substituteAll { mod workspace_layout ; - xwayland = if swayCfg.xwayland then "enable" else "disable"; + xwayland = if config.sane.programs.xwayland.enabled then "enable" else "disable"; } diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index 002dd852..81d1f539 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -310,12 +310,6 @@ in # these could be added, but i don't see much benefit. font = "pango:monospace 10"; mod = "Mod1"; # prefer Alt - # about xwayland: - # - required by many electron apps, though some electron apps support NIXOS_OZONE_WL=1 for native wayland. - # - when xwayland is enabled, KOreader incorrectly chooses the X11 backend - # -> slower; blurrier - # - xwayland uses a small amount of memory (like 30MiB, IIRC?) - xwayland = false; workspace_layout = "tabbed"; screenshot_cmd = "sxmo_screenshot.sh";