diff --git a/nixos/machines/chungus/configuration.nix b/nixos/machines/chungus/configuration.nix index e772989..541ecb3 100644 --- a/nixos/machines/chungus/configuration.nix +++ b/nixos/machines/chungus/configuration.nix @@ -31,7 +31,7 @@ #./tdarr.nix ./rbackup.nix - ./sync-transmission.nix + ./sync-torrent.nix ]; diff --git a/nixos/machines/chungus/sync-transmission.nix b/nixos/machines/chungus/sync-torrent.nix similarity index 88% rename from nixos/machines/chungus/sync-transmission.nix rename to nixos/machines/chungus/sync-torrent.nix index 4f86bec..8177214 100644 --- a/nixos/machines/chungus/sync-transmission.nix +++ b/nixos/machines/chungus/sync-torrent.nix @@ -4,7 +4,7 @@ let in { - containers.torrent = { + containers.sync-torrent = { # mount host folders bindMounts = { @@ -14,7 +14,7 @@ in isReadOnly = false; }; lib = { - hostPath = "/srv/transmission"; + hostPath = "/srv/sync-torrent"; mountPoint = "/var/lib/transmission"; isReadOnly = false; }; @@ -31,7 +31,7 @@ in enable = true; settings = { download-dir = "/media"; - incomplete-dir = "/var/lib/transmission/incomplete"; + incomplete-dir = "/var/lib/transmission/incomplete"; # todo put this somewhere with frequent snapshots but low keep. incomplete-dir-enabled = true; message-level = 1; umask = 2; @@ -86,8 +86,8 @@ in # 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 + # curl -H "Host: sync.chungus.private" https://robi.private/ < will work + # curl -H "Host: sync.chungus.private" https://144.76.13.147/ < wont work services.nginx = { enable = true; recommendedProxySettings = true; diff --git a/nixos/machines/robi/configuration.nix b/nixos/machines/robi/configuration.nix index 649de41..a74cb05 100644 --- a/nixos/machines/robi/configuration.nix +++ b/nixos/machines/robi/configuration.nix @@ -56,6 +56,7 @@ ./sync-opentracker.nix + ./sync-torrent.nix ]; diff --git a/nixos/machines/robi/sync-torrent.nix b/nixos/machines/robi/sync-torrent.nix new file mode 100644 index 0000000..4f131b9 --- /dev/null +++ b/nixos/machines/robi/sync-torrent.nix @@ -0,0 +1,107 @@ +{ lib, pkgs, config, ... }: +let + uiPort = 9099; +in +{ + + containers.sync-torrent = { + + # mount host folders + bindMounts = { + media = { + hostPath = "/media/new"; + mountPoint = "/media"; # must be here otherwise transmission can't see the folder + isReadOnly = false; + }; + lib = { + hostPath = "/srv/sync-torrent"; + 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"; # todo put this somewhere with frequent snapshots but low keep. + 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: sync.robi.private" https://robi.private/ < will work + # curl -H "Host: sync.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}"; + }; + }; + }; + }; + +}