From 44e473db5721c369d7e148a311139dcbfefc70c8 Mon Sep 17 00:00:00 2001
From: makefu <github@syntax-fehler.de>
Date: Wed, 25 Sep 2019 14:19:11 +0200
Subject: [PATCH] ma torrent: log rpc events, cleanup

---
 2configs/elchos/log.nix            |  1 -
 2configs/torrent.nix               | 16 ++++++++++++++--
 2configs/virtualisation/docker.nix |  2 +-
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/2configs/elchos/log.nix b/2configs/elchos/log.nix
index 34bd249..50b4081 100644
--- a/2configs/elchos/log.nix
+++ b/2configs/elchos/log.nix
@@ -1,6 +1,5 @@
 { config, lib, pkgs, ... }:
 
-with import <stockholm/lib>;
 let
 in {
   networking.firewall.allowedTCPPorts = [ 80 443 514 ];
diff --git a/2configs/torrent.nix b/2configs/torrent.nix
index ca368db..9b73653 100644
--- a/2configs/torrent.nix
+++ b/2configs/torrent.nix
@@ -35,7 +35,9 @@ in {
     rtorrent.members = [ "download" ];
   };
 
-  krebs.rtorrent = {
+  krebs.rtorrent = let
+    d = config.makefu.dl-dir;
+  in {
     enable = true;
     web = {
       enable = true;
@@ -45,7 +47,17 @@ in {
     rutorrent.enable = true;
     enableXMLRPC = true;
     listenPort = peer-port;
-    downloadDir = config.makefu.dl-dir;
+    downloadDir = d + "/finished/incoming";
+    watchDir = d + "/watch";
+    # TODO: maybe test out multiple watch dirs with tags: https://github.com/rakshasa/rtorrent/wiki/TORRENT-Watch-directories
+    extraConfig = ''
+      # log.add_output = "debug", "rtorrent-systemd"
+      # log.add_output = "dht_debug", "rtorrent-systemd"
+      # log.add_output = "tracker_debug", "rtorrent-systemd"
+      log.add_output = "rpc_events", "rtorrent-systemd"
+      log.add_output = "rpc_dump", "rtorrent-systemd"
+      system.daemon.set = true
+    '';
     # dump old torrents into watch folder to have them re-added
   };
 
diff --git a/2configs/virtualisation/docker.nix b/2configs/virtualisation/docker.nix
index 951bdbf..b830bc3 100644
--- a/2configs/virtualisation/docker.nix
+++ b/2configs/virtualisation/docker.nix
@@ -5,5 +5,5 @@
     docker
     docker_compose
   ];
-  users.extraUsers.${config.krebs.build.user.name}.extraGroups = [ "docker" ];
+  users.users.${config.krebs.build.user.name}.extraGroups = [ "docker" ];
 }