sway: port xwayland use to sane.programs API

This commit is contained in:
Colin 2024-02-21 23:32:10 +00:00
parent 50c3f04714
commit d1de9efde1
4 changed files with 18 additions and 28 deletions

View File

@ -7,6 +7,15 @@
{ pkgs, ... }: { pkgs, ... }:
{ {
sane.programs.element-desktop = { 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.method = "bwrap";
sandbox.wrapperType = "wrappedDerivation"; sandbox.wrapperType = "wrappedDerivation";
sandbox.net = "clearnet"; sandbox.net = "clearnet";
@ -23,14 +32,7 @@
"tmp" "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 # creds/session keys, etc
persist.byStore.private = [ ".config/Element" ]; persist.byStore.private = [ ".config/Element" ];
suggestedPrograms = [ "gnome-keyring" ];
}; };
} }

View File

@ -29,9 +29,16 @@ let
}; };
swayPackage = wrapSway (pkgs.sway-unwrapped.overrideAttrs (_: { swayPackage = wrapSway (pkgs.sway-unwrapped.overrideAttrs (_: {
# isNixOS = true; #< doesn't matter # 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, # TODO: something else is dragging a xwayland-enabled wlroots into the environment,
# making this actually kinda wasteful. # making this actually kinda wasteful.
enableXWayland = cfg.config.xwayland; enableXWayland = config.sane.programs.xwayland.enabled;
})); }));
in in
{ {
@ -81,14 +88,6 @@ in
- etc - 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 { screenshot_cmd = mkOption {
type = types.str; type = types.str;
@ -199,11 +198,6 @@ in
# icon-theme = lib.mkDefault "Flat-Remix-Grey-Light"; # requires qtbase # 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 { services.gvfs = lib.mkIf cfg.enabled {
enable = true; # allow nautilus to mount remote filesystems (e.g. ftp://...) enable = true; # allow nautilus to mount remote filesystems (e.g. ftp://...)
package = lib.mkDefault (pkgs.gvfs.override { package = lib.mkDefault (pkgs.gvfs.override {

View File

@ -35,5 +35,5 @@ in substituteAll {
mod mod
workspace_layout workspace_layout
; ;
xwayland = if swayCfg.xwayland then "enable" else "disable"; xwayland = if config.sane.programs.xwayland.enabled then "enable" else "disable";
} }

View File

@ -310,12 +310,6 @@ in
# these could be added, but i don't see much benefit. # these could be added, but i don't see much benefit.
font = "pango:monospace 10"; font = "pango:monospace 10";
mod = "Mod1"; # prefer Alt 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"; workspace_layout = "tabbed";
screenshot_cmd = "sxmo_screenshot.sh"; screenshot_cmd = "sxmo_screenshot.sh";