{ config, lib, pkgs, ... }:
{
  imports = [ ./nginx ];

  config = lib.mkIf config.services.transmission.enable {
    services.transmission = {
      credentialsFile = pkgs.writeText "credentials" config.secrets.transmissionCredFile;
      openPeerPorts = true;
      settings = {
        anti-brute-force-enabled = true;
        rpc-authentication-required = true;
        rpc-whitelist-enabled = false;
      };
    };
    environment.persistence."/persist".directories = [ "/var/lib/transmission" ];
  };
}
