{ pkgs, finalDir, downloadDir, watchDir }: let # this needs to be configured in mullvad's settings dhtPort = 55358; rtorrentPort = 54945; in { environment.systemPackages = with pkgs; [ rtorrent ]; users.extraUsers.rtorrent.extraGroups = [ "users" ]; services.rtorrent = { enable = true; port = rtorrentPort; openFirewall = true; downloadDir = downloadDir; # flood needs to be able to access the datadir dataDir = downloadDir; configText = builtins.readFile (pkgs.substituteAll { src = ./rtorrent.rc; watchDir = watchDir; finalDir = finalDir; dhtPort = builtins.toString dhtPort; }); }; networking.firewall = { allowedTCPPorts = [ dhtPort ]; allowedUDPPorts = [ dhtPort rtorrentPort ]; }; }