1 { config, lib, pkgs, ... }:
4 cfg = config.services.torrentstream;
5 dataDir = "/var/lib/torrentstream/";
8 options.services.torrentstream = {
9 enable = lib.mkEnableOption "TorrentStream daemon";
10 package = lib.mkPackageOption pkgs "torrentstream" { };
12 type = lib.types.port;
18 openFirewall = lib.mkOption {
19 type = lib.types.bool;
22 Open ports in the firewall for TorrentStream daemon.
25 address = lib.mkOption {
33 config = lib.mkIf cfg.enable {
34 systemd.services.torrentstream = {
35 after = [ "network.target" ];
36 description = "TorrentStream Daemon";
37 wantedBy = [ "multi-user.target" ];
39 ExecStart = lib.getExe cfg.package;
40 Restart = "on-failure";
42 StateDirectory = "torrentstream";
46 WEB_PORT = toString cfg.port;
47 DOWNLOAD_PATH = "%S/torrentstream";
48 LISTEN_ADDR = cfg.address;
51 networking.firewall.allowedTCPPorts = lib.mkIf cfg.openFirewall [ cfg.port ];