mirror of
https://github.com/Swarsel/.dotfiles.git
synced 2026-04-14 21:29:12 +02:00
70 lines
2.8 KiB
Nix
70 lines
2.8 KiB
Nix
{ pkgs, lib, config, globals, dns, confLib, ... }:
|
|
let
|
|
inherit (confLib.gen { name = "jellyfin"; port = 8096; }) servicePort serviceName serviceUser serviceGroup serviceDomain serviceAddress proxyAddress4 proxyAddress6;
|
|
inherit (confLib.static) isHome isProxied webProxy homeWebProxy dnsServer homeProxyIf webProxyIf nginxAccessRules homeServiceAddress;
|
|
in
|
|
{
|
|
options.swarselmodules.server.${serviceName} = lib.mkEnableOption "enable ${serviceName} on server";
|
|
config = lib.mkIf config.swarselmodules.server.${serviceName} {
|
|
|
|
users = {
|
|
persistentIds.jellyfin = confLib.mkIds 994;
|
|
users.${serviceUser} = {
|
|
extraGroups = [ "video" "render" "users" ];
|
|
};
|
|
};
|
|
# nixpkgs.config.packageOverrides = pkgs: {
|
|
# intel-vaapi-driver = pkgs.intel-vaapi-driver.override { enableHybridCodec = true; };
|
|
# };
|
|
|
|
hardware.graphics = {
|
|
enable = true;
|
|
extraPackages = with pkgs; [
|
|
intel-media-driver # LIBVA_DRIVER_NAME=iHD
|
|
# intel-vaapi-driver # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
|
|
libva-vdpau-driver
|
|
libvdpau-va-gl
|
|
];
|
|
};
|
|
|
|
topology.self.services.${serviceName}.info = "https://${serviceDomain}";
|
|
|
|
globals = {
|
|
networks = {
|
|
${webProxyIf}.hosts = lib.mkIf isProxied {
|
|
${config.node.name}.firewallRuleForNode.${webProxy}.allowedTCPPorts = [ servicePort ];
|
|
};
|
|
${homeProxyIf}.hosts = lib.mkIf isHome {
|
|
${config.node.name}.firewallRuleForNode.${homeWebProxy}.allowedTCPPorts = [ servicePort ];
|
|
};
|
|
};
|
|
services.${serviceName} = {
|
|
domain = serviceDomain;
|
|
inherit proxyAddress4 proxyAddress6 isHome serviceAddress;
|
|
homeServiceAddress = lib.mkIf isHome homeServiceAddress;
|
|
};
|
|
};
|
|
|
|
services.${serviceName} = {
|
|
enable = true;
|
|
user = serviceUser;
|
|
# openFirewall = true; # this works only for the default ports
|
|
};
|
|
|
|
environment.persistence."/state" = lib.mkIf config.swarselsystems.isMicroVM {
|
|
directories = [
|
|
{ directory = "/var/lib/${serviceName}"; user = serviceUser; group = serviceGroup; }
|
|
{ directory = "/var/cache/${serviceName}"; user = serviceUser; group = serviceGroup; }
|
|
];
|
|
};
|
|
|
|
nodes = {
|
|
${dnsServer}.swarselsystems.server.dns.${globals.services.${serviceName}.baseDomain}.subdomainRecords = {
|
|
"${globals.services.${serviceName}.subDomain}" = dns.lib.combinators.host proxyAddress4 proxyAddress6;
|
|
};
|
|
${webProxy}.services.nginx = confLib.genNginx { inherit serviceAddress servicePort serviceDomain serviceName; maxBody = 0; };
|
|
${homeWebProxy}.services.nginx = lib.mkIf isHome (confLib.genNginx { inherit servicePort serviceDomain serviceName; maxBody = 0; extraConfig = nginxAccessRules; serviceAddress = homeServiceAddress; });
|
|
};
|
|
|
|
};
|
|
}
|