{ config, lib, ... }: let cfg = config.profile.services.jellyfin; dataDir = "/nas/mediaserver/jellyfin"; domain = "jellyfin.tigor.web.id"; domain-jellyseerr = "jellyseerr.tigor.web.id"; 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 ''; services.nginx.virtualHosts."${domain}" = { enableACME = true; forceSSL = true; locations = { "= /metrics" = { return = "403"; }; "/" = { proxyPass = "http://0.0.0.0:8096"; proxyWebsockets = true; }; }; }; services.caddy.virtualHosts.${domain}.extraConfig = '' @public not remote_ip private_ranges handle_path /metrics { header @public Content-Type text/html respond @public <