{ config, pkgs, lib, ... }: 
let
  
  tuigreet = "${pkgs.greetd.tuigreet}/bin/tuigreet";
  hyprland-session = "${pkgs.hyprland}/share/wayland-sessions";

  # https://github.com/bytemouse/config/blob/48d9be51a9666c9b62f4b8e84322b9d892ee0aea/modules/gnome.nix#L11
  gnome-script = pkgs.writeShellScriptBin "gnome-script" ''
    export XDG_SESSION_TYPE=wayland 
    ${pkgs.dbus}/bin/dbus-run-session ${pkgs.gnome.gnome-session}/bin/gnome-session
  '';
  gnome-desktop = pkgs.makeDesktopItem {
    name = "gnome-desktop";
    desktopName = "Gnome Desktop";
    exec = "${gnome-script}/bin/gnome-script";
    terminal = true;
  };

in {

  services.greetd = {
    enable = true;
    settings = {
      default_session = {
        command = "${tuigreet} --time --remember --greeting Hoi! --remember-session --sessions ${hyprland-session}:${gnome-desktop}/share/applications";
        user = "greeter";
      };
    };
  };
  environment.systemPackages = with pkgs; [ greetd.tuigreet ];

}