about summary refs log tree commit diff
path: root/modules/piracy/prowlarr.nix
blob: ebcba7f148034836eb0f4108d31dec85a24d04ec (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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{
  config,
  inputs,
  lib,
  libNginx,
  this,
  ...
}:
let
  cfg = config.nixfiles.modules.piracy.prowlarr;

  port = 9696;
in
{
  options.nixfiles.modules.piracy.prowlarr = {
    enable = lib.mkEnableOption "Prowlarr";

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

  config = lib.mkIf cfg.enable {
    # secrets.prowlarr-api-key.file = "${inputs.self}/secrets/prowlarr-api-key";

    ark.directories = [ "/var/lib/private/prowlarr" ];

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

    services = {
      prowlarr.enable = true;

      prometheus.exporters.exportarr-prowlarr = {
        enable = true;
        url = "http://127.0.0.1";
        port = port + 10000;
        apiKeyFile = config.secrets.lidarr-api-key.path;
        listenAddress = this.wireguard.ipv4.address;
        environment = {
          PROWLARR__BACKFILL = "true";
          PROWLARR__BACKFILL_DATE_SINCE = "2025-01-01";
        };
      };
    };

    topology.nodes.${this.hostname}.services.prowlarr = {
      name = "Prowlarr";
      icon = "${inputs.homelab-svg-assets}/assets/prowlarr.svg";
      info = cfg.domain;
      details.listen.text = "127.0.0.1:${toString port}";
    };
  };
}

Consider giving Nix/NixOS a try! <3