about summary refs log tree commit diff
path: root/modules/jackett.nix
blob: 5b0b2c0698edf717f80f1cbc7739e45db5cf0548 (plain) (blame)
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
35
36
37
38
39
40
41
42
43
44
45
46
{
  config,
  inputs,
  lib,
  libNginx,
  this,
  ...
}:
let
  cfg = config.nixfiles.modules.jackett;
in
{
  options.nixfiles.modules.jackett = {
    enable = lib.mkEnableOption "Jackett";

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

  config = lib.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;

    topology = with cfg; {
      nodes.${this.hostname}.services.jackett = {
        name = "Jackett";
        icon = "${inputs.homelab-svg-assets}/assets/jackett.svg";
        info = domain;
        details.listen.text = "127.0.0.1:9117";
      };
    };
  };
}

Consider giving Nix/NixOS a try! <3