2016-08-21 09:55:46 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
2016-10-20 18:54:38 +00:00
|
|
|
with import <stockholm/lib>;
|
2016-08-21 09:55:46 +00:00
|
|
|
|
|
|
|
let
|
2016-12-22 14:41:49 +00:00
|
|
|
basicAuth = import <torrent-secrets/auth.nix>;
|
2016-08-21 09:55:46 +00:00
|
|
|
peer-port = 51412;
|
|
|
|
web-port = 8112;
|
|
|
|
daemon-port = 58846;
|
2018-10-21 21:20:19 +00:00
|
|
|
base-dir = config.krebs.rtorrent.workDir;
|
2016-08-21 09:55:46 +00:00
|
|
|
in {
|
|
|
|
|
|
|
|
users.users = {
|
|
|
|
download = {
|
|
|
|
name = "download";
|
2018-08-06 15:52:48 +00:00
|
|
|
home = base-dir;
|
2017-04-24 21:22:13 +00:00
|
|
|
uid = mkDefault (genid "download");
|
2016-08-21 09:55:46 +00:00
|
|
|
createHome = true;
|
|
|
|
useDefaultShell = true;
|
|
|
|
group = "download";
|
|
|
|
openssh.authorizedKeys.keys = [ ];
|
|
|
|
};
|
|
|
|
};
|
2016-08-24 10:16:18 +00:00
|
|
|
|
2016-08-21 09:55:46 +00:00
|
|
|
users.extraGroups = {
|
|
|
|
download = {
|
2017-04-24 21:22:13 +00:00
|
|
|
gid = lib.mkDefault (genid "download");
|
2016-08-21 09:55:46 +00:00
|
|
|
members = [
|
|
|
|
config.krebs.build.user.name
|
|
|
|
"download"
|
2016-08-24 10:16:18 +00:00
|
|
|
"rtorrent"
|
|
|
|
"nginx"
|
2016-08-21 09:55:46 +00:00
|
|
|
];
|
|
|
|
};
|
2018-08-06 15:52:48 +00:00
|
|
|
rtorrent.members = [ "download" ];
|
2016-08-21 09:55:46 +00:00
|
|
|
};
|
|
|
|
|
2016-08-24 15:51:22 +00:00
|
|
|
krebs.rtorrent = {
|
2016-08-21 09:55:46 +00:00
|
|
|
enable = true;
|
2016-08-24 10:16:18 +00:00
|
|
|
web = {
|
|
|
|
enable = true;
|
2016-12-22 14:41:49 +00:00
|
|
|
port = web-port;
|
|
|
|
inherit basicAuth;
|
2016-08-21 09:55:46 +00:00
|
|
|
};
|
2016-08-24 10:16:18 +00:00
|
|
|
rutorrent.enable = true;
|
|
|
|
enableXMLRPC = true;
|
|
|
|
listenPort = peer-port;
|
2018-10-21 21:20:19 +00:00
|
|
|
downloadDir = config.makefu.dl-dir;
|
2016-08-24 10:16:18 +00:00
|
|
|
# dump old torrents into watch folder to have them re-added
|
2016-08-21 09:55:46 +00:00
|
|
|
};
|
|
|
|
|
2018-10-21 21:20:19 +00:00
|
|
|
services.nginx.virtualHosts."torrent.${config.krebs.build.host.name}.r".locations."/" = { proxyPass = "http://localhost:${toString web-port}/"; };
|
|
|
|
|
2016-08-21 09:55:46 +00:00
|
|
|
networking.firewall.extraCommands = ''
|
2016-08-24 10:16:18 +00:00
|
|
|
iptables -A INPUT -i retiolum -p tcp --dport ${toString web-port} -j ACCEPT
|
2016-08-21 09:55:46 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ peer-port ];
|
|
|
|
networking.firewall.allowedUDPPorts = [ peer-port ];
|
2018-10-21 21:20:19 +00:00
|
|
|
state = [ config.krebs.rtorrent.sessionDir ]; # state which torrents were loaded
|
2016-08-21 09:55:46 +00:00
|
|
|
}
|