stockholm/makefu/2configs/torrent.nix

72 lines
1.6 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2016-10-20 18:54:38 +00:00
with import <stockholm/lib>;
let
daemon-user = "tor";
basicAuth = import <torrent-secrets/auth.nix>;
peer-port = 51412;
web-port = 8112;
daemon-port = 58846;
base-dir = config.makefu.dl-dir;
in {
users.users = {
download = {
name = "download";
home = base-dir;
2017-04-24 21:22:13 +00:00
uid = mkDefault (genid "download");
createHome = true;
useDefaultShell = true;
group = "download";
openssh.authorizedKeys.keys = [ ];
};
};
2016-08-24 10:16:18 +00:00
# todo: race condition, do this after download user has been created
system.activationScripts."download-dir-chmod" = ''
for i in finished watch; do
if test ! -d $i;then
mkdir -p "${base-dir}/$i"
chown rtorrent:download "${base-dir}/$i"
chmod 775 "${base-dir}/$i"
fi
done
'';
users.extraGroups = {
download = {
2017-04-24 21:22:13 +00:00
gid = lib.mkDefault (genid "download");
members = [
config.krebs.build.user.name
"download"
2016-08-24 10:16:18 +00:00
"rtorrent"
"nginx"
];
};
rtorrent.members = [ "download" ];
};
2016-08-24 15:51:22 +00:00
krebs.rtorrent = {
enable = true;
2016-08-24 10:16:18 +00:00
web = {
enable = true;
port = web-port;
inherit basicAuth;
};
2016-08-24 10:16:18 +00:00
rutorrent.enable = true;
enableXMLRPC = true;
listenPort = peer-port;
downloadDir = base-dir + "/finished";
watchDir = base-dir + "/watch";
2016-08-24 10:16:18 +00:00
# dump old torrents into watch folder to have them re-added
};
networking.firewall.extraCommands = ''
2016-08-24 10:16:18 +00:00
iptables -A INPUT -i retiolum -p tcp --dport ${toString web-port} -j ACCEPT
'';
networking.firewall.allowedTCPPorts = [ peer-port ];
networking.firewall.allowedUDPPorts = [ peer-port ];
}