Files
nix/modules/homelab/services/arr/sonarr/default.nix

66 lines
1.6 KiB
Nix

{ pkgs, config, lib, ... }:
let
cfg = config.modules.services.sonarr;
ids = lib.mkForce 2005;
default_port = 8989;
in
{
options.modules.services.sonarr = {
enable = lib.mkEnableOption "enables sonarr";
port = lib.mkOption {
type = lib.types.int;
default = 8989;
description = "set port for sonarr (${toString default_port})";
};
};
config = lib.mkIf cfg.enable {
# declare sonarr group
users.groups.sonarr = { gid = ids; };
# declare sonarr user
users.users.sonarr = {
description = "sonarr media server user";
uid = ids;
isSystemUser = true;
home = "/var/lib/sonarr";
createHome = true;
group = "sonarr";
extraGroups = [ "media" ];
};
# enable the sonarr service
services.sonarr = {
enable = true;
openFirewall = true;
user = "sonarr";
group = "sonarr";
dataDir = "/var/lib/sonarr";
settings = {
server.port = cfg.port; # default: 8989
};
};
# override umask to make permissions work out
systemd.services.sonarr.serviceConfig = { UMask = lib.mkForce "0007"; };
# open firewall
#networking.firewall.allowedTCPPorts = [ cfg.port ];
# reverse proxy entryo
services.nginx.virtualHosts."sonarr.snowbelle.lan" = {
enableACME = false;
forceSSL = true;
sslCertificate = config.sops.secrets."ssl_blakedheld_crt".path;
sslCertificateKey = config.sops.secrets."ssl_blakedheld_key".path;
locations."/" = {
proxyPass = "http://127.0.0.1:${toString cfg.port}";
};
};
};
}