about summary refs log tree commit diff
path: root/modules/piracy
diff options
context:
space:
mode:
Diffstat (limited to 'modules/piracy')
-rw-r--r--modules/piracy/default.nix2
-rw-r--r--modules/piracy/jackett.nix12
-rw-r--r--modules/piracy/lidarr.nix17
-rw-r--r--modules/piracy/prowlarr.nix62
-rw-r--r--modules/piracy/radarr.nix17
-rw-r--r--modules/piracy/sonarr.nix17
6 files changed, 89 insertions, 38 deletions
diff --git a/modules/piracy/default.nix b/modules/piracy/default.nix
index 3554a02..1410827 100644
--- a/modules/piracy/default.nix
+++ b/modules/piracy/default.nix
@@ -9,7 +9,7 @@ let
   cfg = config.nixfiles.modules.piracy;
 in
 {
-  imports = lib.attrValues (lib.modulesIn ./.);
+  imports = lib.modulesIn ./. |> lib.attrValues;
 
   options.nixfiles.modules.piracy = {
     enable = lib.mkEnableOption "tools for working with the BitTorrent protocol";
diff --git a/modules/piracy/jackett.nix b/modules/piracy/jackett.nix
index 7ef9311..c26216e 100644
--- a/modules/piracy/jackett.nix
+++ b/modules/piracy/jackett.nix
@@ -34,13 +34,11 @@ in
 
     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";
-      };
+    topology.nodes.${this.hostname}.services.jackett = {
+      name = "Jackett";
+      icon = "${inputs.homelab-svg-assets}/assets/jackett.svg";
+      info = cfg.domain;
+      details.listen.text = "127.0.0.1:9117";
     };
   };
 }
diff --git a/modules/piracy/lidarr.nix b/modules/piracy/lidarr.nix
index a905d8e..400ba9f 100644
--- a/modules/piracy/lidarr.nix
+++ b/modules/piracy/lidarr.nix
@@ -6,7 +6,6 @@
   this,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.piracy.lidarr;
 
@@ -14,16 +13,16 @@ let
 in
 {
   options.nixfiles.modules.piracy.lidarr = {
-    enable = mkEnableOption "Lidarr";
+    enable = lib.mkEnableOption "Lidarr";
 
-    domain = mkOption {
+    domain = lib.mkOption {
       description = "Domain name sans protocol scheme.";
-      type = with types; str;
+      type = lib.types.str;
       default = "lidarr.${config.networking.domain}";
     };
   };
 
-  config = mkIf cfg.enable {
+  config = lib.mkIf cfg.enable {
     secrets.lidarr-api-key.file = "${inputs.self}/secrets/lidarr-api-key";
 
     ark.directories = [ "/var/lib/lidarr" ];
@@ -74,11 +73,9 @@ in
       ];
     };
 
-    topology = with cfg; {
-      nodes.${this.hostname}.services.lidarr = {
-        info = domain;
-        details.listen.text = "127.0.0.1:${toString port}";
-      };
+    topology.nodes.${this.hostname}.services.lidarr = {
+      info = cfg.domain;
+      details.listen.text = "127.0.0.1:${toString port}";
     };
   };
 }
diff --git a/modules/piracy/prowlarr.nix b/modules/piracy/prowlarr.nix
new file mode 100644
index 0000000..ebcba7f
--- /dev/null
+++ b/modules/piracy/prowlarr.nix
@@ -0,0 +1,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}";
+    };
+  };
+}
diff --git a/modules/piracy/radarr.nix b/modules/piracy/radarr.nix
index ac2fe7f..12f8d95 100644
--- a/modules/piracy/radarr.nix
+++ b/modules/piracy/radarr.nix
@@ -6,7 +6,6 @@
   this,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.piracy.radarr;
 
@@ -14,16 +13,16 @@ let
 in
 {
   options.nixfiles.modules.piracy.radarr = {
-    enable = mkEnableOption "Radarr";
+    enable = lib.mkEnableOption "Radarr";
 
-    domain = mkOption {
+    domain = lib.mkOption {
       description = "Domain name sans protocol scheme.";
-      type = with types; str;
+      type = lib.types.str;
       default = "radarr.${config.networking.domain}";
     };
   };
 
-  config = mkIf cfg.enable {
+  config = lib.mkIf cfg.enable {
     secrets.radarr-api-key.file = "${inputs.self}/secrets/radarr-api-key";
 
     ark.directories = [ "/var/lib/radarr" ];
@@ -74,11 +73,9 @@ in
       ];
     };
 
-    topology = with cfg; {
-      nodes.${this.hostname}.services.radarr = {
-        info = domain;
-        details.listen.text = "127.0.0.1:${toString port}";
-      };
+    topology.nodes.${this.hostname}.services.radarr = {
+      info = cfg.domain;
+      details.listen.text = "127.0.0.1:${toString port}";
     };
   };
 }
diff --git a/modules/piracy/sonarr.nix b/modules/piracy/sonarr.nix
index 8715a12..0761a3d 100644
--- a/modules/piracy/sonarr.nix
+++ b/modules/piracy/sonarr.nix
@@ -6,7 +6,6 @@
   this,
   ...
 }:
-with lib;
 let
   cfg = config.nixfiles.modules.piracy.sonarr;
 
@@ -14,16 +13,16 @@ let
 in
 {
   options.nixfiles.modules.piracy.sonarr = {
-    enable = mkEnableOption "Sonarr";
+    enable = lib.mkEnableOption "Sonarr";
 
-    domain = mkOption {
+    domain = lib.mkOption {
       description = "Domain name sans protocol scheme.";
-      type = with types; str;
+      type = lib.types.str;
       default = "sonarr.${config.networking.domain}";
     };
   };
 
-  config = mkIf cfg.enable {
+  config = lib.mkIf cfg.enable {
     secrets.sonarr-api-key.file = "${inputs.self}/secrets/sonarr-api-key";
 
     ark.directories = [ "/var/lib/sonarr" ];
@@ -74,11 +73,9 @@ in
       ];
     };
 
-    topology = with cfg; {
-      nodes.${this.hostname}.services.sonarr = {
-        info = domain;
-        details.listen.text = "127.0.0.1:${toString port}";
-      };
+    topology.nodes.${this.hostname}.services.sonarr = {
+      info = cfg.domain;
+      details.listen.text = "127.0.0.1:${toString port}";
     };
   };
 }

Consider giving Nix/NixOS a try! <3