{ lib, config, ... }: let cfg = config.ptw.services.greetd; in { options.ptw.services.greetd = { enable = lib.mkEnableOption "Enable greetd with gtkgreet"; swayExtra = lib.mkOption { description = "Extra options to include in the sway config"; default = ""; }; }; config = lib.mkIf cfg.enable { users.users.greeter = { isSystemUser = lib.mkForce false; isNormalUser = true; createHome = true; uid = 992; }; services = { greetd = { enable = true; restart = true; settings = { default_session = let swayConfig = pkgs.writeText "login-sway-config" '' exec ${pkgs.greetd.gtkgreet}/bin/gtkgreet -l; ${pkgs.sway}/bin/swaymsg exit; bindsym Mod4+shift+e exec swaynag \ -t warning \ -m 'What do you want to do?' \ -b 'Poweroff' 'systemctl poweroff' \ -b 'Reboot' 'systemctl reboot' input "*" { xkb_layout de } ${cfg.swayExtra} include /etc/sway/config.d/* ''; in { command = "${pkgs.sway}/bin/sway --config ${swayConfig}"; user = "greeter"; }; }; }; }; }; }