2024-06-17 23:28:22 +07:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.profile.services.jellyfin;
|
|
|
|
dataDir = "/nas/mediaserver/jellyfin";
|
|
|
|
domain = "jellyfin.tigor.web.id";
|
2024-07-04 14:03:10 +07:00
|
|
|
domain-jellyseerr = "jellyseerr.tigor.web.id";
|
2024-06-17 23:28:22 +07:00
|
|
|
inherit (lib) mkIf;
|
|
|
|
username = config.profile.user.name;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
users.users.${username}.extraGroups = [ "jellyfin" ];
|
|
|
|
users.users.jellyfin.extraGroups = [ username ];
|
|
|
|
system.activationScripts.jellyfin-prepare = ''
|
|
|
|
mkdir -p ${dataDir}
|
|
|
|
chmod -R 0777 /nas/mediaserver
|
|
|
|
'';
|
2024-11-24 20:16:30 +07:00
|
|
|
|
2024-11-24 20:46:15 +07:00
|
|
|
services.nginx.virtualHosts."${domain}" = {
|
2024-11-24 21:31:04 +07:00
|
|
|
useACMEHost = "tigor.web.id";
|
2024-11-24 20:46:15 +07:00
|
|
|
forceSSL = true;
|
|
|
|
locations = {
|
|
|
|
"= /metrics" = {
|
2024-11-24 21:49:24 +07:00
|
|
|
proxyPass = "http://0.0.0.0:8096";
|
|
|
|
extraConfig =
|
|
|
|
#nginx
|
|
|
|
''
|
|
|
|
if ($auth_ip != off) {
|
|
|
|
return 403;
|
|
|
|
}
|
|
|
|
'';
|
2024-11-24 20:46:15 +07:00
|
|
|
};
|
|
|
|
"/" = {
|
|
|
|
proxyPass = "http://0.0.0.0:8096";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-11-24 21:31:04 +07:00
|
|
|
security.acme.certs."tigor.web.id".extraDomainNames = [
|
|
|
|
domain
|
|
|
|
domain-jellyseerr
|
|
|
|
];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${domain-jellyseerr}" = mkIf cfg.jellyseerr.enable {
|
|
|
|
useACMEHost = "tigor.web.id";
|
2024-11-24 20:46:15 +07:00
|
|
|
forceSSL = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://0.0.0.0:5055";
|
|
|
|
proxyWebsockets = true;
|
|
|
|
};
|
|
|
|
};
|
2024-06-17 23:28:22 +07:00
|
|
|
services.jellyfin = {
|
|
|
|
enable = true;
|
|
|
|
inherit dataDir;
|
|
|
|
};
|
2024-06-26 16:34:41 +07:00
|
|
|
|
2024-10-21 12:31:30 +07:00
|
|
|
services.jellyseerr = mkIf cfg.jellyseerr.enable { enable = true; };
|
2024-09-16 23:53:48 +07:00
|
|
|
|
2024-10-21 12:31:30 +07:00
|
|
|
environment.etc."alloy/config.alloy".text = # hcl
|
|
|
|
''
|
|
|
|
prometheus.scrape "jellyfin" {
|
|
|
|
targets = [{__address__ = "0.0.0.0:8096"}]
|
|
|
|
job_name = "jellyfin"
|
|
|
|
forward_to = [prometheus.remote_write.mimir.receiver]
|
|
|
|
}
|
|
|
|
'';
|
2024-06-17 23:28:22 +07:00
|
|
|
};
|
|
|
|
}
|