From 57c69e91ef8f5bb7f8846ba11da68a2075b0c5c4 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Thu, 19 Feb 2026 19:06:40 -0500 Subject: [PATCH] sonarr: init --- configuration.nix | 1 + flake.nix | 5 +++++ services/arr/sonarr.nix | 42 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 services/arr/sonarr.nix diff --git a/configuration.nix b/configuration.nix index c13c951..a37204a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -33,6 +33,7 @@ ./services/bitmagnet.nix ./services/arr/prowlarr.nix + ./services/arr/sonarr.nix ./services/soulseek.nix diff --git a/flake.nix b/flake.nix index 4b55d0c..1744fde 100644 --- a/flake.nix +++ b/flake.nix @@ -126,6 +126,7 @@ livekit = 7880; lk_jwt = 8081; prowlarr = 9696; + sonarr = 8989; }; https = { @@ -197,6 +198,10 @@ prowlarr = { dataDir = services_dir + "/prowlarr"; }; + + sonarr = { + dataDir = services_dir + "/sonarr"; + }; }; }; diff --git a/services/arr/sonarr.nix b/services/arr/sonarr.nix new file mode 100644 index 0000000..ac3da89 --- /dev/null +++ b/services/arr/sonarr.nix @@ -0,0 +1,42 @@ +{ + pkgs, + config, + service_configs, + lib, + ... +}: +{ + imports = [ + (lib.serviceMountWithZpool "sonarr" service_configs.zpool_ssds [ + service_configs.sonarr.dataDir + ]) + (lib.serviceMountWithZpool "sonarr" service_configs.zpool_hdds [ + service_configs.torrents_path + ]) + (lib.serviceFilePerms "sonarr" [ + "Z ${service_configs.sonarr.dataDir} 0700 ${config.services.sonarr.user} ${config.services.sonarr.group}" + ]) + ]; + + systemd.tmpfiles.rules = [ + "d /torrents/media 2775 root ${service_configs.media_group} -" + "d ${service_configs.media.tvDir} 2775 root ${service_configs.media_group} -" + "d ${service_configs.media.moviesDir} 2775 root ${service_configs.media_group} -" + ]; + + services.sonarr = { + enable = true; + dataDir = service_configs.sonarr.dataDir; + settings.server.port = service_configs.ports.sonarr; + settings.update.mechanism = "external"; + }; + + services.caddy.virtualHosts."sonarr.${service_configs.https.domain}".extraConfig = '' + import ${config.age.secrets.caddy_auth.path} + reverse_proxy :${builtins.toString service_configs.ports.sonarr} + ''; + + users.users.${config.services.sonarr.user}.extraGroups = [ + service_configs.media_group + ]; +}