nix/graphical/desktop/wry.nix
2026-04-08 11:51:33 +10:00

64 lines
1.9 KiB
Nix

{
inputs,
pkgs,
lib,
getFlakePkg,
...
}:
let
wry = getFlakePkg inputs.wry;
wry-session = pkgs.writeShellScript "wry-session" ''
systemctl --user import-environment
dbus-update-activation-environment --all
systemctl --user start wry-session-bridge.service &
exec ${lib.getExe wry} run
'';
in
{
options.programs.wry = {
package = lib.mkOption {
type = lib.types.package;
default = wry;
};
};
config = {
environment.systemPackages = [ wry ];
services.greetd = {
enable = true;
settings.default_session.command = "${lib.getExe (getFlakePkg inputs.tuigreet)} --sessions /etc/greetd/wayland-sessions --remember-session";
};
environment.etc."greetd/wayland-sessions/wry.desktop".text = ''
[Desktop Entry]
Name=wry
Exec=${wry-session}
Type=Application
DesktopNames=wry
'';
# bridge service to activate graphical-session.target for direct-launched wry.
# waits for wry IPC readiness before pulling in the target.
systemd.user.services.wry-session-bridge = {
unitConfig = {
Description = "Activate graphical-session.target for direct-launched wry";
BindsTo = [ "graphical-session.target" ];
Before = [ "graphical-session.target" ];
Wants = [ "graphical-session-pre.target" ];
After = [ "graphical-session-pre.target" ];
};
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
# wry's IPC goes through the Wayland socket,
# so we can't use a wry subcommand without WAYLAND_DISPLAY already set.
# Wait for wry to create its wayland socket in XDG_RUNTIME_DIR instead.
ExecStart = pkgs.writeShellScript "wry-ready" ''
until find "$XDG_RUNTIME_DIR" -maxdepth 1 -name "wayland-*" ! -name "*.lock" -type s | grep -q .; do
sleep 0.1
done
'';
};
};
};
}