{ config, pkgs, lib, ... }: let
  empttyConf = pkgs.writeText "emptty-config" ''
    TTY_NUMBER=7

    WAYLAND_SESSIONS_PATH="${config.services.displayManager.sessionData.desktops}/share/wayland-sessions"
  '';
in {
  services.displayManager = {
    enable = true;
    execCmd = "${pkgs.emptty}/bin/emptty -d";
  };
  systemd.services.display-manager = {
    enable = true;
    path = [pkgs.dwl];
    serviceConfig = {
      EnvironmentFile = empttyConf;
      Type="idle";
      TTYPath="/dev/tty7";
      TTYReset="yes";
      SendSIGHUP="yes";
      KillMode="process";
    };
  };

  security.pam.services = {
    emptty.text = ''
      auth	substack	sshd
      account	include	sshd
      password	substack	sshd
      session	include sshd
    '';
  };
}
