nixos/modules/services/sonarr/default.nix

70 lines
1.5 KiB
Nix
Raw Normal View History

2023-03-15 22:34:36 +01:00
# manages and downloads series
2023-11-07 22:00:00 +01:00
{ config, lib, ... }:
2023-03-15 22:34:36 +01:00
let
cfg = config.my.services.sonarr;
2023-11-07 23:13:51 +01:00
inherit (config.networking) domain;
2023-03-15 22:34:36 +01:00
port = 8989;
in
{
options.my.services.sonarr = with lib; {
enable = mkEnableOption "Sonarr for series management";
2023-07-25 22:20:49 +02:00
apiKeyFile = lib.mkOption {
type = lib.types.path;
2024-12-30 12:01:57 +01:00
description = ''
2023-07-25 22:20:49 +02:00
File containing the api-key.
'';
};
2023-03-15 22:34:36 +01:00
};
config = lib.mkIf cfg.enable {
# TODO: remove when sonarr is updated to 5.x
nixpkgs.config.permittedInsecurePackages = [
"dotnet-sdk-6.0.428"
"aspnetcore-runtime-6.0.36"
];
services = {
sonarr = {
enable = true;
};
prometheus.exporters.exportarr-sonarr = {
inherit (config.services.prometheus) enable;
port = port + 1;
url = "http://localhost:${toString port}";
inherit (cfg) apiKeyFile;
};
prometheus.scrapeConfigs = [
{
job_name = "sonarr";
2024-07-28 21:08:02 +02:00
static_configs = [
{
targets = [ "localhost:${toString port + 1}" ];
2024-07-28 21:08:02 +02:00
labels = {
instance = config.networking.hostName;
};
}
];
}
];
2023-03-15 22:34:36 +01:00
};
my.services.webserver.virtualHosts = [
2023-03-15 22:34:36 +01:00
{
subdomain = "series";
inherit port;
}
];
webapps.apps.sonarr = {
dashboard = {
2023-04-02 17:50:15 +02:00
name = "Series";
2023-04-02 17:43:28 +02:00
category = "media";
2023-03-15 22:34:36 +01:00
icon = "tv";
2023-11-12 20:39:44 +01:00
url = "https://series.${domain}";
2024-06-16 22:24:11 +02:00
method = "get";
2023-03-15 22:34:36 +01:00
};
};
};
}