about summary refs log tree commit diff
path: root/modules/services/transmission.nix
blob: e32ca6a178a032e50813013cd766ae664aff2dd9 (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
{ config, lib, ... }:

with lib;
let
  cfg = config.modules.services.transmission;
in
{
  options.modules.services.transmission = {
    enable = mkEnableOption "";

    home = mkOption { type = types.str; };
    secrets.transmission-extra-config = mkOption {
      type = types.path;
      description = ''
        Path to the secret file containing the extra config JSON.
        Useful for setting passwords (`rpc-password`).
        Hashed password should be used as transmission will try to
        rewrite the config with hashed password if plaintext password
        is used. Hashed password starts with the character `{`.
      '';
    };
  };

  config = mkIf cfg.enable {
    services.transmission = {
      enable = true;

      home = cfg.home;

      settings = {
        # Require encrypted connections
        encryption = 2;

        # Web interface
        rpc-port = 4006;
        rpc-authentication-required = true;
        # Managed via external ACL
        rpc-host-whitelist-enabled = false;

        # Start torrents as soon as they are added
        start-added-torrents = true;

        incomplete-dir-enabled = true;
        incomplete-dir = "${cfg.home}/incomplete";
        download-dir = "${cfg.home}/downloads";
        watch-dir-enabled = false;
        watch-dir = "${cfg.home}/watch";
      };

      credentialsFile = cfg.secrets.transmission-extra-config;
    };
  };
}