{
  config,
  lib,
  pkgs,
  namespace,
  ...
}:
with lib;
let
  name = "arrs";
  cfg = config.${namespace}.services.${name};

  arrsConfig = lib.${namespace}.mkModule {
    inherit config name;
    serviceName = "sabnzbd";
    description = "*arr Services";
    options = { };
    moduleConfig = {
      # Enable radarr service
      services.radarr = {
        enable = true;
        openFirewall = cfg.openFirewall;
        user = "nix-apps";
        group = "jallen-nas";
        dataDir = "${cfg.configDir}/radarr";
      };

      # Enable Sonarr service
      services.sonarr = {
        enable = true;
        openFirewall = cfg.openFirewall;
        user = "nix-apps";
        group = "jallen-nas";
        dataDir = "${cfg.configDir}/sonarr";
        package = pkgs.unstable.sonarr;
      };

      # Enable Sabnzbd service
      services.sabnzbd = {
        enable = true;
        # openFirewall = cfg.openFirewall;
        user = "nix-apps";
        group = "jallen-nas";
        configFile = "${cfg.configDir}/sabnzbd/sabnzbd.ini";
      };

      services.deluge = {
        enable = false;
        user = "nix-apps";
        group = "jallen-nas";
        openFirewall = cfg.openFirewall;
        dataDir = cfg.dataDir;
        web = {
          enable = true;
          port = 8112;
          openFirewall = cfg.openFirewall;
        };
      };

      services.jackett = {
        enable = false;
        user = "nix-apps";
        group = "jallen-nas";
        openFirewall = cfg.openFirewall;
      };
    };
  };
in
{
  imports = [ arrsConfig ];
}
