From 2449611bce39fa9716eb7f04e61bfa774605c11a Mon Sep 17 00:00:00 2001 From: Felix Buehler Date: Thu, 30 Nov 2023 23:38:42 +0100 Subject: [PATCH] service/arr: migrate to nixos exportarr --- modules/services/bazarr/default.nix | 30 ++++++++++++++-- modules/services/prowlarr/default.nix | 51 +++++++++++---------------- modules/services/radarr/default.nix | 43 +++++++++++----------- modules/services/sonarr/default.nix | 41 ++++++++++----------- 4 files changed, 92 insertions(+), 73 deletions(-) diff --git a/modules/services/bazarr/default.nix b/modules/services/bazarr/default.nix index 870629f..cc84b1a 100644 --- a/modules/services/bazarr/default.nix +++ b/modules/services/bazarr/default.nix @@ -8,11 +8,37 @@ in { options.my.services.bazarr = with lib; { enable = mkEnableOption "Bazarr for subtitle management"; + + apiKeyFile = lib.mkOption { + type = lib.types.path; + description = lib.mdDoc '' + File containing the api-key. + ''; + }; }; config = lib.mkIf cfg.enable { - services.bazarr = { - enable = true; + services = { + bazarr = { + enable = true; + }; + prometheus.exporters.exportarr-bazarr = { + inherit (config.services.prometheus) enable; + port = port + 1; + url = "http://127.0.0.1:${toString port}"; + inherit (cfg) apiKeyFile; + }; + prometheus.scrapeConfigs = [ + { + job_name = "bazarr"; + static_configs = [{ + targets = [ "127.0.0.1:${toString port + 1}" ]; + labels = { + instance = config.networking.hostName; + }; + }]; + } + ]; }; systemd.services.bazarr = { diff --git a/modules/services/prowlarr/default.nix b/modules/services/prowlarr/default.nix index 1d7b64f..99d4930 100644 --- a/modules/services/prowlarr/default.nix +++ b/modules/services/prowlarr/default.nix @@ -18,19 +18,28 @@ in }; config = lib.mkIf cfg.enable { - services.prowlarr = { - enable = true; + services = { + prowlarr = { + enable = true; + }; + prometheus.exporters.exportarr-prowlarr = { + inherit (config.services.prometheus) enable; + port = port + 1; + url = "http://127.0.0.1:${toString port}"; + inherit (cfg) apiKeyFile; + }; + prometheus.scrapeConfigs = [ + { + job_name = "prowlarr"; + static_configs = [{ + targets = [ "127.0.0.1:${toString port + 1}" ]; + labels = { + instance = config.networking.hostName; + }; + }]; + } + ]; }; - # # ugly fix for service not having a homedirectory - # users.users.prowlarr = { - # isSystemUser = true; - # home = "/var/lib/prowlarr"; - # group = "prowlarr"; - # uid = 61654; - # }; - # users.groups.prowlarr = { - # gid = 61654; - # }; systemd.services.prowlarr = { after = [ "network-online.target" ]; @@ -43,24 +52,6 @@ in } ]; - my.services.exportarr.prowlarr = { - port = port + 1; - url = "http://127.0.0.1:${toString port}"; - inherit (cfg) apiKeyFile; - }; - - services.prometheus.scrapeConfigs = [ - { - job_name = "prowlarr"; - static_configs = [{ - targets = [ "127.0.0.1:${toString port + 1}" ]; - labels = { - instance = config.networking.hostName; - }; - }]; - } - ]; - webapps.apps.prowlarr = { dashboard = { name = "Indexer"; diff --git a/modules/services/radarr/default.nix b/modules/services/radarr/default.nix index d083cd9..214c74e 100644 --- a/modules/services/radarr/default.nix +++ b/modules/services/radarr/default.nix @@ -7,7 +7,7 @@ let in { options.my.services.radarr = with lib; { - enable = mkEnableOption "Radarr for films management"; + enable = mkEnableOption "Radarr for film management"; apiKeyFile = lib.mkOption { type = lib.types.path; @@ -18,8 +18,27 @@ in }; config = lib.mkIf cfg.enable { - services.radarr = { - enable = true; + services = { + radarr = { + enable = true; + }; + prometheus.exporters.exportarr-radarr = { + inherit (config.services.prometheus) enable; + port = port + 1; + url = "http://127.0.0.1:${toString port}"; + inherit (cfg) apiKeyFile; + }; + prometheus.scrapeConfigs = [ + { + job_name = "radarr"; + static_configs = [{ + targets = [ "127.0.0.1:${toString port + 1}" ]; + labels = { + instance = config.networking.hostName; + }; + }]; + } + ]; }; systemd.services.radarr = { @@ -33,24 +52,6 @@ in } ]; - my.services.exportarr.radarr = { - port = port + 1; - url = "http://127.0.0.1:${toString port}"; - inherit (cfg) apiKeyFile; - }; - - services.prometheus.scrapeConfigs = [ - { - job_name = "radarr"; - static_configs = [{ - targets = [ "127.0.0.1:${toString port + 1}" ]; - labels = { - instance = config.networking.hostName; - }; - }]; - } - ]; - webapps.apps.radarr = { dashboard = { name = "Movies"; diff --git a/modules/services/sonarr/default.nix b/modules/services/sonarr/default.nix index 6f48e3b..316e250 100644 --- a/modules/services/sonarr/default.nix +++ b/modules/services/sonarr/default.nix @@ -18,8 +18,27 @@ in }; config = lib.mkIf cfg.enable { - services.sonarr = { - enable = true; + services = { + sonarr = { + enable = true; + }; + prometheus.exporters.exportarr-sonarr = { + inherit (config.services.prometheus) enable; + port = port + 1; + url = "http://127.0.0.1:${toString port}"; + inherit (cfg) apiKeyFile; + }; + prometheus.scrapeConfigs = [ + { + job_name = "sonarr"; + static_configs = [{ + targets = [ "127.0.0.1:${toString port + 1}" ]; + labels = { + instance = config.networking.hostName; + }; + }]; + } + ]; }; systemd.services.sonarr = { @@ -33,24 +52,6 @@ in } ]; - my.services.exportarr.sonarr = { - port = port + 1; - url = "http://127.0.0.1:${toString port}"; - inherit (cfg) apiKeyFile; - }; - - services.prometheus.scrapeConfigs = [ - { - job_name = "sonarr"; - static_configs = [{ - targets = [ "127.0.0.1:${toString port + 1}" ]; - labels = { - instance = config.networking.hostName; - }; - }]; - } - ]; - webapps.apps.sonarr = { dashboard = { name = "Series";