{ config, pkgs, lib, ... }:
let
  tbProfile = pkgs.stdenv.mkDerivation {
    name = "thunderbird-profile";
    src = ./thunderbird-profile;

    installPhase = ''
      mkdir -p $out
      cp -r . $out/
    '';
  };
in
{
    environment.systemPackages = with pkgs; [
        # New system packages
    ];

    programs.thunderbird = {
        enable = true;
        package = pkgs.thunderbird;

        policies = {
            DisableTelemetry = true;
            DisableAppUpdate = true;

            Preferences = {
                "mail.provider.enabled" = false;
                "mail.openpgp.allow_external_gnupg" = true;
                "calendar.timezone.local" = "Europe/Berlin";
            };

            Certificates = {
                ImportEnterpriseRoots = true;
            };

            PasswordManagerEnabled = true;
            Cookies = {
                "Default" = false;
                "AcceptThirdParty" = "never";
                "Locked" = true;
            };

            DefaultDownloadDirectory = "/tmp";
            DisableBuiltinPDFViewer = true;
            DisablePasswordReveal = true;
        };
    };
}
