about summary refs log tree commit diff
path: root/modules/prowlarr.nix
blob: c5bf5c0873cbfb490777b3c62976eebba058e727 (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
63
64
65
{
  config,
  inputs,
  lib,
  libNginx,
  this,
  ...
}:
with lib;
let
  cfg = config.nixfiles.modules.prowlarr;

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

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

  config = 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 = with cfg; {
      nodes.${this.hostname}.services.prowlarr = {
        name = "Prowlarr";
        icon = "${inputs.homelab-svg-assets}/assets/prowlarr.svg";
        info = domain;
        details.listen.text = "127.0.0.1:${toString port}";
      };
    };
  };
}

Consider giving Nix/NixOS a try! <3