nixos/hosts/architect/jellyfin.nix

65 lines
2.1 KiB
Nix
Raw Normal View History

{ config, pkgs, lib, ... }:
2021-07-13 09:53:22 +01:00
2022-04-05 13:05:08 +01:00
let
domain = "media.giugl.io";
port = 8096;
utilities = import ./utilities.nix { inherit lib config; };
inherit (utilities) architectInterfaceAddress;
2022-11-20 13:55:59 +00:00
in
{
# needed since StateDirectory does not accept symlinks
systemd.services.jellyfin.serviceConfig.StateDirectory = lib.mkForce "";
2021-07-07 13:13:19 +01:00
services = {
jellyfin = {
2021-11-25 11:42:32 +00:00
enable = true;
2022-03-15 15:58:04 +00:00
group = "media";
package = pkgs.unstablePkgs.jellyfin;
};
2021-07-07 13:13:19 +01:00
2022-02-15 10:58:08 +00:00
nginx.virtualHosts.${domain} = {
2022-04-05 13:05:08 +01:00
forceSSL = true;
enableACME = true;
extraConfig = ''
# External Javascript (such as cast_sender.js for Chromecast) must be whitelisted.
#add_header Content-Security-Policy "default-src https: data: blob: http://image.tmdb.org; style-src 'self' 'unsafe-inline'; script-src 'self' 'unsafe-inline' https://www.gstatic.com/cv/js/sender/v1/cast_sender.js https://www.gstatic.com/eureka/clank/95/cast_sender.js https://www.gstatic.com/eureka/clank/96/cast_sender.js https://www.gstatic.com/eureka/clank/97/cast_sender.js https://www.youtube.com blob:; worker-src 'self' blob:; connect-src 'self'; object-src 'none'; frame-ancestors 'self'";
# Disable buffering when the nginx proxy gets very resource heavy upon streaming
proxy_buffering off;
allow ${config.architect.networks.lan.net};
allow ${config.architect.networks.tailscale.net};
deny all;
'';
2021-07-07 13:13:19 +01:00
locations."/" = {
proxyPass = "http://127.0.0.1:${toString port}";
2022-04-05 13:05:08 +01:00
};
2022-04-05 13:05:08 +01:00
locations."/socket" = {
proxyPass = "http://127.0.0.1:${toString port}";
2022-04-05 13:05:08 +01:00
proxyWebsockets = true;
2021-07-07 13:13:19 +01:00
};
};
};
2021-07-07 13:13:19 +01:00
networking.extraHosts = ''
${architectInterfaceAddress "lan"} ${domain}
${architectInterfaceAddress "wireguard"} ${domain}
${architectInterfaceAddress "tailscale"} ${domain}
2021-07-07 13:13:19 +01:00
'';
users.groups = {
media.members = [ "jellyfin" ];
video.members = [ "jellyfin" ];
render.members = [ "jellyfin" ];
};
2022-03-15 15:58:04 +00:00
fileSystems."/tmp/jellyfin" = {
device = "none";
fsType = "tmpfs";
options = [ "defaults" "size=20G" "uid=jellyfin" ];
};
2021-07-07 13:13:19 +01:00
}