sway: simplify the wrapper... slightly

This commit is contained in:
Colin 2024-02-21 21:42:48 +00:00
parent f068da709f
commit 4da9cb5ac8

View File

@ -4,7 +4,7 @@
# sway-config docs: `man 5 sway`
let
cfg = config.sane.gui.sway;
wrapSway = sway': swayOverrideArgs: let
wrapSway = configuredSway: let
# `wrapSway` exists to create a `sway.desktop` file
# which will launch sway with our desired debugging facilities.
# i.e. redirect output to syslog.
@ -14,12 +14,10 @@ let
echo "launching sway-session (sway.desktop)..." | ${systemd-cat} --identifier=sway-session
sway 2>&1 | ${systemd-cat} --identifier=sway-session
'';
# this override is what `programs.nixos` would do internally if we left `package` unset.
configuredSway = sway'.override swayOverrideArgs;
desktop-file = pkgs.runCommand "sway-desktop-wrapper" {} ''
mkdir -p $out/share/wayland-sessions
substitute ${configuredSway}/share/wayland-sessions/sway.desktop $out/share/wayland-sessions/sway.desktop \
--replace 'Exec=sway' 'Exec=${swayWithLogger}/bin/sway-session'
--replace-fail 'Exec=sway' 'Exec=${swayWithLogger}/bin/sway-session'
# XXX(2023/09/24) phog greeter (mobile greeter) will crash if DesktopNames is not set
echo "DesktopNames=Sway" >> $out/share/wayland-sessions/sway.desktop
'';
@ -30,11 +28,9 @@ let
paths = [ desktop-file configuredSway ];
passthru = {
inherit (configuredSway.passthru) providedSessions;
# nixos/modules/programs/wayland/sway.nix will call `.override` on the package we provide it
override = wrapSway sway';
};
};
swayPackage = wrapSway pkgs.sway {
swayPackage = wrapSway (pkgs.sway.override {
extraOptions = [
# "--debug"
];
@ -45,16 +41,18 @@ let
export SWAYSOCK="$XDG_RUNTIME_DIR/sway-ipc.sock"
'';
# withBaseWrapper sets XDG_CURRENT_DESKTOP=sway
# and makes sure that sway is launched dbus-run-session.
withBaseWrapper = true;
dbusSupport = false; #< not needed; dbus session is started as part of login/pam stuff i think
# "wrapGAppsHook wrapper to execute sway with required environment variables for GTK applications."
# this literally just sets XDG_DATA_DIRS to the gtk3 gsettings-schemas before launching sway.
# notably, this pulls in the *build* gtk3 -- probably not in an incompatible way
# but still as a mistake, and wasteful for cross compilation
withGtkWrapper = false;
isNixOS = true;
# TODO: something else is dragging a xwayland-enabled wlroots into the environment,
# making this actually kinda wasteful.
enableXWayland = cfg.config.xwayland;
};
});
in
{
options = with lib; {