{ config, pkgs, lib, mkDomain, ... }:
{
  # Nitter
  # Alternative Twitter front-end

  services.nitter = {
    enable = true;
    package = pkgs.unstable.nitter;
    #openFirewall
    #config.base64Media = false; # Use base64 encoding for proxied media URLs.
    server.title = "Pjitter";
    server.address = "127.0.0.1";
    server.hostname = mkDomain "nitter";
    server.https = true; # Secure cookies
    server.port = 4965;
    #preferences.autoplayGifs = ; # default is true
    #preferences.bidiSupport = ; # Support bidirectional text (makes clicking on tweets harder). default is false
    #preferences.hideBanner = ; # Hide profile banner. default is false
    #preferences.hidePins = ; # Hide pinned tweets. default is false
    #preferences.hideReplies = ; # Hide tweet replies. default is false
    #preferences.hideTweetStats = ; # Hide tweet stats (replies, retweets, likes). default is false
    preferences.hlsPlayback = true; # Enable HLS video streaming (requires JavaScript). default is false
    preferences.infiniteScroll = true; # Infinite scrolling (requires JavaScript, experimental!). default is false
    #preferences.mp4Playback = ; # Enable MP4 video playback. default is true
    #preferences.muteVideos = ; # Mute videos by default. default is false
    #preferences.proxyVideos = ; # Proxy video streaming through the server (might be slow). default is true
    #preferences.replaceInstagram = "bibliogram.art"; # Replace Instagram links with links to this instance (blank to disable). default is ""
    preferences.replaceTwitter = mkDomain "nitter"; # Replace Twitter links with links to this instance (blank to disable). default is ""
    preferences.replaceYouTube = lib.mkIf config.services.invidious.enable (mkDomain "invidious"); # Replace YouTube links with links to this instance (blank to disable). default is ""
    settings = lib.mkIf config.services.libreddit.enable  {
      Preferences.replaceReddit = mkDomain "libreddit"; # Replace Reddit links with links to this instance (blank to disable). default is ""
    };
    #preferences.stickyProfile = ; # Make profile sidebar stick to top. default is true
    preferences.theme = "Twitter Dark"; # Instance theme. default is "Nitter"
  };
  services.nginx.virtualHosts.${mkDomain "nitter"} = lib.mkIf config.services.nitter.enable {
    forceSSL = true; # addSSL = true;
    enableACME = true; #useACMEHost = acmeDomain;
    locations."/" = {
      proxyPass = "http://127.0.0.1:${toString config.services.nitter.server.port}";
      proxyWebsockets = true;
    };
  };

}
