self-hosting/modules/jellyfin.nix

46 lines
1,019 B
Nix
Raw Normal View History

2024-03-26 23:37:53 +01:00
{ config, lib, ... }:
2024-12-10 11:39:55 +01:00
let
cfg = config.custom.services.jellyfin;
in
{
2024-03-26 23:37:53 +01:00
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 {
2024-12-10 11:39:55 +01:00
services.jellyfin = {
enable = true;
dataDir = "/nix/var/data/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
};
};
}