{ config, pkgs, lib, ... }:

let
  nomarchy-sddm-theme = pkgs.stdenv.mkDerivation {
    pname = "nomarchy-sddm-theme";
    version = "1.0";
    src = ./sddm/nomarchy;
    nativeBuildInputs = [ pkgs.libsForQt5.qt5.wrapQtAppsHook ];
    installPhase = ''
      mkdir -p $out/share/sddm/themes/nomarchy
      cp -r * $out/share/sddm/themes/nomarchy/
    '';
    propagatedBuildInputs = with pkgs.libsForQt5.qt5; [
      qtgraphicaleffects
      qtquickcontrols2
      qtsvg
    ];
  };
in
{
  services.xserver.enable = lib.mkDefault true;
  services.displayManager.sddm = {
    enable = lib.mkDefault true;
    wayland.enable = lib.mkDefault true;
    theme = lib.mkDefault "nomarchy";
  };

  services.displayManager.defaultSession = lib.mkDefault "hyprland-uwsm";

  services.displayManager.autoLogin = {
    enable = lib.mkDefault true;
    user = lib.mkDefault "nomarchy";
  };

  environment.systemPackages = lib.mkDefault [ nomarchy-sddm-theme ];

  # Enable Hyprland system-level dependencies
  programs.hyprland = {
    enable = lib.mkDefault true;
    withUWSM = lib.mkDefault true;
  };
  programs.uwsm.enable = lib.mkDefault true;
}
