From 86076f08444054b228996fcc417d7789bd66b712 Mon Sep 17 00:00:00 2001 From: Noah Masur <7386960+nmasur@users.noreply.github.com> Date: Sun, 12 Mar 2023 13:24:16 +0000 Subject: [PATCH] add arr services --- hosts/swan/default.nix | 1 + modules/nixos/services/arr.nix | 71 +++++++++++++++++++++++++ modules/nixos/services/default.nix | 1 + modules/nixos/services/transmission.nix | 4 +- 4 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 modules/nixos/services/arr.nix diff --git a/hosts/swan/default.nix b/hosts/swan/default.nix index a9aa306..07e9452 100644 --- a/hosts/swan/default.nix +++ b/hosts/swan/default.nix @@ -42,6 +42,7 @@ nixpkgs.lib.nixosSystem { streamServer = "stream.masu.rs"; nextcloudServer = "cloud.masu.rs"; bookServer = "books.masu.rs"; + arrServer = "download.masu.rs"; samba.enable = true; backup.s3 = { diff --git a/modules/nixos/services/arr.nix b/modules/nixos/services/arr.nix new file mode 100644 index 0000000..393ec27 --- /dev/null +++ b/modules/nixos/services/arr.nix @@ -0,0 +1,71 @@ +{ config, lib, ... }: + +{ + + options = { + arrServer = lib.mkOption { + type = lib.types.str; + description = "Hostname for arr services"; + default = null; + }; + }; + + config = lib.mkIf (config.arrServer != null) { + + services.sonarr.enable = true; + services.radarr.enable = true; + services.bazarr.enable = true; + services.prowlarr.enable = true; + + # Requires updating the base_url config value in each service + # If you try to rewrite the URL, the service won't redirect properly + caddy.routes = [ + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/sonarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:8989"; }]; + }]; + } + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/radarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:7878"; }]; + }]; + } + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/prowlarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:9696"; }]; + }]; + } + { + group = "download"; + match = [{ + host = [ config.arrServer ]; + path = [ "/bazarr*" ]; + }]; + handle = [{ + handler = "reverse_proxy"; + upstreams = [{ dial = "localhost:6767"; }]; + }]; + } + ]; + + }; + +} diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index 46f9ed7..9fb0c07 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -1,6 +1,7 @@ { ... }: { imports = [ + ./arr.nix ./backups.nix ./caddy.nix ./calibre.nix diff --git a/modules/nixos/services/transmission.nix b/modules/nixos/services/transmission.nix index fc805c1..ff470b2 100644 --- a/modules/nixos/services/transmission.nix +++ b/modules/nixos/services/transmission.nix @@ -41,7 +41,9 @@ }; # Create reverse proxy for web UI - caddy.routes = [{ + caddy.routes = lib.mkAfter [{ + group = + lib.mkIf (config.arrServer == config.transmissionServer) "download"; match = [{ host = [ config.transmissionServer ]; }]; handle = [{ handler = "reverse_proxy";