self-hosting/modules/jellyfin.nix

44 lines
1.1 KiB
Nix
Raw Normal View History

2024-03-26 23:37:53 +01:00
{ config, lib, ... }:
let cfg = config.custom.services.jellyfin;
in {
options.custom.services.jellyfin = {
enable = lib.mkEnableOption "jellyfin";
2021-12-07 01:55:01 +01:00
};
2024-03-26 23:37:53 +01:00
config = lib.mkIf cfg.enable {
services.jellyfin = { enable = true; };
2021-12-07 01:55:01 +01:00
2024-03-26 23:37:53 +01:00
systemd.services.jellyfin.serviceConfig.ExecStart = lib.mkOverride 10
"${config.services.jellyfin.package}/bin/jellyfin --datadir '/nix/var/data/jellyfin' --cachedir '/var/cache/jellyfin'";
2021-12-07 01:55:01 +01:00
2024-03-26 23:37:53 +01:00
services.nginx.virtualHosts."jellyfin.${config.networking.domain}" = {
enableACME = true;
forceSSL = true;
2021-12-07 01:55:01 +01:00
2024-03-26 23:37:53 +01:00
locations."= /".extraConfig = ''
return 302 https://$host/web/;
2021-12-07 01:55:01 +01:00
'';
2024-03-26 23:37:53 +01:00
locations."/" = {
proxyPass = "http://127.0.0.1:8096";
extraConfig = ''
proxy_buffering off;
'';
};
2021-12-07 01:55:01 +01:00
2024-03-26 23:37:53 +01:00
locations."= /web/" = {
proxyPass = "http://127.0.0.1:8096/web/index.html";
};
locations."/socket" = {
proxyPass = "http://127.0.0.1:8096";
extraConfig = ''
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
'';
};
2021-12-07 01:55:01 +01:00
};
};
}