summaryrefslogtreecommitdiff
path: root/modules/nixos/jackett.nix
blob: 772e0e9f8a8a2981bc1f2c16df5872b9b99dc918 (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
{
  config,
  lib,
  libNginx,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.jackett;
in {
  options.nixfiles.modules.jackett = {
    enable = mkEnableOption "Jackett";

    domain = mkOption {
      description = "Domain name sans protocol scheme.";
      type = with types; str;
      default = "jackett.${config.networking.domain}";
    };
  };

  config = mkIf cfg.enable {
    ark.directories = ["/var/lib/jackett"];

    nixfiles.modules.nginx = {
      enable = true;
      upstreams.jackett.servers."127.0.0.1:9117" = {};
      virtualHosts.${cfg.domain} = {
        locations."/".proxyPass = "http://jackett";
        extraConfig = libNginx.config.internalOnly;
      };
    };

    services.jackett.enable = true;
  };
}