summary refs log tree commit diff
path: root/services/torrent/flood.nix
blob: ae0385e9ea4abd693c0ef9a33e5164d576d3d64f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{
  lib,
  pkgs,
  me,
  unstablePkgs,
  auxiliaryPkgs,
  ...
}:

let
  inherit (pkgs) dockerTools mediainfo;
  inherit (auxiliaryPkgs) common;

  flood = unstablePkgs.flood;

  torrentLocalPort = 2018;
  torrentWebLocalPort = 2019;
  torrentDir = "/srv/torrent";

  floodImage = dockerTools.streamLayeredImage {
    name = "flood";
    tag = flood.version;
    fromImage = common.alpine.base;
    contents = [ flood mediainfo ];
  };
in
{
  foundation.services.torrent-webui = {
    image = floodImage;

    ports = [ torrentWebLocalPort ];

    volumes = [
      [
        "${torrentDir}/download"
        "/download"
      ]
    ];

    entrypoint = lib.getExe flood;
    cmd = [
      "--host" "0.0.0.0"
      "--port" "${toString torrentWebLocalPort}"
      "--rundir" "${torrentDir}/flood"
      "--auth" "none"

      # pick one according to which is running!
      # "--qburl" "http://${me.tailscale.ip}:${toString torrentLocalPort}"
      # "--qbuser" "admin"
      # "--qbpass" "admin"
      "--trurl" "http://${me.tailscale.ip}:${toString torrentLocalPort}/transmission/rpc"
      "--truser" "admin"
      "--trpass" "admin"
    ];
  };

  services.nginx.virtualHosts."bt.rnrd.fyi" = {
    useACMEHost = "rnrd.fyi";
    forceSSL = true;
    listenAddresses = [ me.tailscale.ip ];
    locations."/" = {
      proxyPass = "http://127.0.0.1:${toString torrentWebLocalPort}/";
      recommendedProxySettings = true;
    };
  };
}