about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--modules/services/transmission.nix53
1 files changed, 53 insertions, 0 deletions
diff --git a/modules/services/transmission.nix b/modules/services/transmission.nix
new file mode 100644
index 0000000..e32ca6a
--- /dev/null
+++ b/modules/services/transmission.nix
@@ -0,0 +1,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;
+    };
+  };
+}