{ config, lib, pkgs, ... }: let inherit (lib) mkIf mkForce; cfg = config.pepe.services.jellyfin; in { options.pepe.services.jellyfin = with lib; { enable = mkEnableOption "Enable jellyfin"; package = mkPackageOption pkgs "jellyfin" { }; domain = mkOption { type = types.str; default = null; }; tmpfsSize = mkOption { type = types.str; default = "20G"; description = "Size of the tmpfs mount for Jellyfin"; }; }; config = mkIf cfg.enable { # needed since StateDirectory does not accept symlinks systemd.services.jellyfin.serviceConfig.StateDirectory = mkForce ""; architect.vhost.${cfg.domain} = with config.architect.networks; { dnsInterfaces = [ "lan" "tailscale" ]; locations = { "/" = { port = 8096; allowLan = true; allow = [ tailscale.net ]; }; "/socket" = { port = 8096; allowLan = true; proxyWebsockets = true; allow = [ tailscale.net ]; }; }; }; services.jellyfin = { enable = true; group = "media"; package = cfg.package; }; users.groups = { video.members = [ "jellyfin" ]; render.members = [ "jellyfin" ]; }; pepe.core.media.groupMembers = mkIf config.pepe.core.media.enable [ "jellyfin" ]; fileSystems."/tmp/jellyfin" = { device = "none"; fsType = "tmpfs"; options = [ "defaults" "size=${cfg.tmpfsSize}" "uid=jellyfin" ]; }; }; }