nix/graphical/desktop/wry.nix
2026-05-20 16:02:24 +10:00

62 lines
1.8 KiB
Nix

{
inputs,
pkgs,
lib,
getFlakePkg,
config,
...
}:
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 = {
enable = lib.mkEnableOption "wry compositor";
package = lib.mkOption {
type = lib.types.package;
default = wry;
};
};
config = lib.mkIf (config.programs.wry.enable) {
environment.systemPackages = [ wry ];
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
'';
};
};
};
}