From f5b76b2f83ab600c85ee1e1d4956c8c449945179 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Wed, 3 May 2023 21:20:51 +0200 Subject: [PATCH] init torrent sync --- nixos/components/network/tinc/private.nix | 2 + nixos/machines/chungus/configuration.nix | 1 + nixos/machines/chungus/sync-transmission.nix | 107 +++++++++++++++++++ nixos/machines/robi/configuration.nix | 2 + nixos/machines/robi/sync-opentracker.nix | 5 + nixos/machines/robi/transmission2.nix | 2 - 6 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 nixos/machines/chungus/sync-transmission.nix create mode 100644 nixos/machines/robi/sync-opentracker.nix diff --git a/nixos/components/network/tinc/private.nix b/nixos/components/network/tinc/private.nix index fad6b8c..f40eded 100644 --- a/nixos/components/network/tinc/private.nix +++ b/nixos/components/network/tinc/private.nix @@ -23,6 +23,7 @@ let "loki.robi" = hosts.robi; "grafana.robi" = hosts.robi; "prometheus.robi" = hosts.robi; + "sync.robi" = hosts.robi; # pepe "loki.pepe" = hosts.pepe; "grafana.pepe" = hosts.pepe; @@ -35,6 +36,7 @@ let "prometheus.chungus" = hosts.chungus; "tts.chungus" = hosts.chungus; "tdarr.chungus" = hosts.chungus; + "sync.chungus" = hosts.chungus; }; network = "private"; in diff --git a/nixos/machines/chungus/configuration.nix b/nixos/machines/chungus/configuration.nix index afc530c..e772989 100644 --- a/nixos/machines/chungus/configuration.nix +++ b/nixos/machines/chungus/configuration.nix @@ -31,6 +31,7 @@ #./tdarr.nix ./rbackup.nix + ./sync-transmission.nix ]; diff --git a/nixos/machines/chungus/sync-transmission.nix b/nixos/machines/chungus/sync-transmission.nix new file mode 100644 index 0000000..4f86bec --- /dev/null +++ b/nixos/machines/chungus/sync-transmission.nix @@ -0,0 +1,107 @@ +{ lib, pkgs, config, ... }: +let + uiPort = 9099; +in +{ + + containers.torrent = { + + # mount host folders + bindMounts = { + media = { + hostPath = "/media"; + mountPoint = "/media"; # must be here otherwise transmission can't see the folder + isReadOnly = false; + }; + lib = { + hostPath = "/srv/transmission"; + mountPoint = "/var/lib/transmission"; + isReadOnly = false; + }; + }; + + autoStart = true; + + config = { config, pkgs, lib, ... }: { + + system.stateVersion = "22.11"; + services.journald.extraConfig = "SystemMaxUse=1G"; + + services.transmission = { + enable = true; + settings = { + download-dir = "/media"; + incomplete-dir = "/var/lib/transmission/incomplete"; + incomplete-dir-enabled = true; + message-level = 1; + umask = 2; + rpc-whitelist-enabled = false; + rpc-host-whitelist-enabled = false; + rpc-port = uiPort; + rpc-enable = true; + rpc-bind-address = "0.0.0.0"; + + # "normal" speed limits + speed-limit-down-enabled = false; + speed-limit-down = 800; + speed-limit-up-enabled = true; + speed-limit-up = 3000; + upload-slots-per-torrent = 8; + # Queuing + # When true, Transmission will only download + # download-queue-size non-stalled torrents at once. + download-queue-enabled = true; + download-queue-size = 3; + + # When true, torrents that have not shared data for + # queue-stalled-minutes are treated as 'stalled' + # and are not counted against the queue-download-size + # and seed-queue-size limits. + queue-stalled-enabled = true; + queue-stalled-minutes = 60; + + # When true. Transmission will only seed seed-queue-size + # non-stalled torrents at once. + seed-queue-enabled = false; + seed-queue-size = 10; + + # Enable UPnP or NAT-PMP. + peer-port = 51413; + port-forwarding-enabled = false; + # Start torrents as soon as they are added + + start-added-torrents = true; + + }; + }; + + }; + }; + + # open ports for logging + #networking.firewall.interfaces."ve-torrent".allowedTCPPorts = + # [ 5044 12304 12305 ]; + #networking.firewall.interfaces."ve-torrent".allowedUDPPorts = + # [ 5044 12304 12305 ]; + + # host nginx setup + # ---------------- + # curl -H "Host: transmission.robi.private" https://robi.private/ < will work + # curl -H "Host: transmission.robi.private" https://144.76.13.147/ < wont work + services.nginx = { + enable = true; + recommendedProxySettings = true; + virtualHosts = { + "sync.${config.networking.hostName}.private" = { + extraConfig = '' + allow ${config.tinc.private.subnet}; + deny all; + ''; + locations."/" = { + proxyPass = "http://127.0.0.1:${toString uiPort}"; + }; + }; + }; + }; + +} diff --git a/nixos/machines/robi/configuration.nix b/nixos/machines/robi/configuration.nix index 16ff9e4..649de41 100644 --- a/nixos/machines/robi/configuration.nix +++ b/nixos/machines/robi/configuration.nix @@ -54,6 +54,8 @@ ./grafana.nix ./telegraf.nix + + ./sync-opentracker.nix ]; diff --git a/nixos/machines/robi/sync-opentracker.nix b/nixos/machines/robi/sync-opentracker.nix new file mode 100644 index 0000000..aaec2bd --- /dev/null +++ b/nixos/machines/robi/sync-opentracker.nix @@ -0,0 +1,5 @@ +{ + services.opentracker = { + enable = true; + }; +} diff --git a/nixos/machines/robi/transmission2.nix b/nixos/machines/robi/transmission2.nix index 604ced3..02b4613 100644 --- a/nixos/machines/robi/transmission2.nix +++ b/nixos/machines/robi/transmission2.nix @@ -65,8 +65,6 @@ in }; }; - # container network setup - # see also nating on host system. autoStart = true; config = { config, pkgs, lib, ... }: {