{
  lib,
  config,
  pkgs,
  ...
}: let
  inherit (lib) mkEnableOption mkIf mkOption types;
  cfg = config.horseman.boot.greeter.greetd;
  homeCfg = config.horseman;
in {
  options = {
    horseman.boot.greeter.greetd = {
      enable = mkEnableOption "Greetd Greeter";
      session = mkOption {type = types.str;};
    };
  };

  config = mkIf cfg.enable {
    environment.systemPackages = with pkgs; [
      greetd.tuigreet
    ];

    services.greetd = {
      enable = true;
      settings = {
        default_session = {
          user = homeCfg.username;
          command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --remember --remember-session --greeting 'Please authenticate to continue' --asterisks --asterisks-char '*' --theme 'border=74;text=cyan;prompt=green;time=cyan;action=cyan;button=cyan;container=black;input=238' --cmd ${cfg.session}";
        };
      };
    };

    systemd.services.greetd.serviceConfig = {
      Type = "idle";
      StandardInput = "tty";
      StandardOutput = "tty";
      StandardError = "journal"; # Without this errors will spam on screen
      # Without these bootlogs will spam on screen
      TTYReset = true;
      TTYVHangup = true;
      TTYVTDisallocate = true;
    };
  };
}
