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

let
  cfg = config.de;
in {
  imports = [
    ./kde.nix
    ./xfce.nix
    ./yubikey.nix
    ./chromium.nix
#    ./firefox.nix
    ./audio.nix
#    ./torbrowser.nix
    ./pithos.nix
    ./spotify.nix
    ./vscodium.nix
    # FIXME make optional
#    ./discord.nix
#    ./steam.nix
    ./touchpad.nix
    ./mount-samba.nix
  ];

  options.de = {
    enable = lib.mkEnableOption "enable desktop environment";
    enableAcceleration = lib.mkOption {
      type = lib.types.bool;
      default = true;
    };
  };

  config = lib.mkIf cfg.enable {
    # vulkan
   hardware.opengl.driSupport = de.enableAcceleration;
   hardware.opengl.driSupport32Bit = de.enableAcceleration;

    # Applications
    users.users.googlebot.packages = with pkgs; [
      chromium
      keepassxc
      mumble
      tigervnc
      bluez-tools
      vscodium
      element-desktop
      mpv
      nextcloud-client
#      signal-desktop # FIXME
      gparted
      libreoffice-fresh
      thunderbird
      spotifyd
      spotify-qt
      arduino
      yt-dlp
      jellyfin-media-player
    ];

    # Networking
    networking.networkmanager.enable = true;
    users.users.googlebot.extraGroups = [ "networkmanager" ];

    # Printing
    services.printing.enable = true;
    services.printing.drivers = with pkgs; [
      gutenprint
    ];
    # Printer discovery
    services.avahi.enable = true;
    services.avahi.nssmdns = true;

    programs.file-roller.enable = true;

    # Security
    services.gnome.gnome-keyring.enable = true;
    security.pam.services.googlebot.enableGnomeKeyring = true;
  };
}
