summaryrefslogtreecommitdiffstats
path: root/lass/2configs/downloading.nix
blob: b9f3449e4d603413e5df9df6048c860c64d4ca77 (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
67
68
69
70
71
72
73
74
{ config, lib, pkgs, ... }:

with lib;
{
  imports = [
    ../3modules/folderPerms.nix
  ];

  users.extraUsers = {
    download = {
      name = "download";
      home = "/var/download";
      createHome = true;
      useDefaultShell = true;
      extraGroups = [
        "download"
      ];
      openssh.authorizedKeys.keys = [
        config.krebs.users.lass.pubkey
      ];
    };

    transmission = {
      extraGroups = [
        "download"
      ];
    };
  };

  users.extraGroups = {
    download = {
      members = [
        "download"
        "transmission"
      ];
    };
  };

  services.transmission = {
    enable = true;
    settings = {
      download-dir = "/var/download/finished";
      incomplete-dir = "/var/download/incoming";
      incomplete-dir-enabled = true;

      rpc-authentication-required = true;
      rpc-whitelist-enabled = false;
      rpc-username = "download";
      #add rpc-password in secrets
      rpc-password = "test123";
      peer-port = 51413;
    };
  };

  krebs.iptables = {
    enable = true;
    tables.filter.INPUT.rules = [
      { predicate = "-p tcp --dport 9091"; target = "ACCEPT"; }
      { predicate = "-p tcp --dport 51413"; target = "ACCEPT"; }
      { predicate = "-p udp --dport 51413"; target = "ACCEPT"; }
    ];
  };

  lass.folderPerms = {
    enable = true;
    permissions = [
      {
        path = "/var/download";
        permission = "775";
        owner = "transmission:download";
      }
    ];
  };
}