# SPDX-FileCopyrightText: 2020 Luke Granger-Brown <depot@lukegb.com>
#
# SPDX-License-Identifier: Apache-2.0

{ depot, lib, pkgs, rebuilder, config, ... }:
let
  inherit (depot.ops) secrets;
in {
  imports = [
    ./content.nix
  ];

  users.users.deluge.extraGroups = [ "content" ];
  users.users.lukegb.extraGroups = [ "deluge" ];

  services.deluge = {
    enable = true;
    declarative = true;
    openFirewall = true;
    dataDir = "/store/deluge";
    config = {
      upnp = false;
      natpmp = false;
      max_active_seeding = 900;
      max_active_downloading = 100;
      max_active_limit = 1000;
      move_completed_paths_list = [ "/store/content/Anime" "/store/content/Films" "/store/content/TV" ];
      enabled_plugins = [ "Label" ];
    };
    authFile = secrets.deluge.authFile;

    web.enable = true;
    package = depot.pkgs.deluge;
  };
}