big restructure, wrappers
This commit is contained in:
@@ -1,74 +0,0 @@
|
||||
{ pkgs, config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.modules.services.sonarr;
|
||||
ids = lib.mkForce 2005;
|
||||
default_port = 8989;
|
||||
data_dir = "/var/lib/sonarr";
|
||||
in
|
||||
{
|
||||
options.modules.services.sonarr = {
|
||||
enable = lib.mkEnableOption "enables sonarr";
|
||||
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
default = 7107;
|
||||
description = "set port for sonarr (${toString default_port})";
|
||||
};
|
||||
|
||||
backup = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
||||
# declare sonarr group
|
||||
users.groups.sonarr = { gid = ids; };
|
||||
|
||||
# declare sonarr user
|
||||
users.users.sonarr = {
|
||||
description = "sonarr 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 = data_dir;
|
||||
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}";
|
||||
};
|
||||
};
|
||||
|
||||
# add to backups
|
||||
modules.system.backups.paths = lib.mkIf cfg.backup [ data_dir ];
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user