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

with lib;
let
  cfg = config.my.programs.gnome;

  extensions = with pkgs.gnomeExtensions; [
    gsconnect
    vitals
    gtile
    blur-my-shell
  ];
in
{
  options.my.programs.gnome.enable = mkEnableOption "gnome";

  config = lib.mkIf cfg.enable {
    hardware = {
      opengl = {
        enable = true;
        driSupport = true;
      };
      pulseaudio.enable = false;
    };
    services.xserver = {
      layout = "de";
      displayManager = {
        autoLogin = {
          enable = true;
          user = "moritz";
        };
        gdm.enable = true;
      };
      enable = true;
      desktopManager.gnome.enable = true;
    };
    environment.systemPackages = extensions;
    home-manager.users.moritz.dconf.settings = {
      "org/gnome/shell" = {
        disable-user-extensions = false;
        enabled-extensions = map (p: p.extensionUuid or p.uuid) extensions;
      };
      "org/gnome/desktop/interface".enable-hot-corners = false;
      "org/gnome/desktop/wm/preferences".focus-mode = "sloppy";
    };
  };
}
