From 6d24800e965d89223f82ca8fd5b8c6cff902d2b5 Mon Sep 17 00:00:00 2001 From: KoenDR06 Date: Thu, 19 Feb 2026 00:58:56 +0100 Subject: [PATCH] jellyfin container --- modules/containers/default.nix | 1 + modules/containers/jellyfin.nix | 96 +++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 modules/containers/jellyfin.nix diff --git a/modules/containers/default.nix b/modules/containers/default.nix index 38005d6..04c8b5e 100644 --- a/modules/containers/default.nix +++ b/modules/containers/default.nix @@ -10,6 +10,7 @@ in { ./nginx.nix ./forgejo.nix ./vaultwarden.nix + ./jellyfin.nix ]; options = { diff --git a/modules/containers/jellyfin.nix b/modules/containers/jellyfin.nix new file mode 100644 index 0000000..8da7e40 --- /dev/null +++ b/modules/containers/jellyfin.nix @@ -0,0 +1,96 @@ +{ + inputs, + outputs, + lib, + config, + pkgs, + ... +}: let + inherit (lib) types mkOption mkEnableOption mkIf; + cfg = config.horseman.containers.jellyfin; + username = config.horseman.username; + + # BACKUP_DIR = config.horseman.containers.backupDir; + DATA_DIR = "/home/${username}/backups/volumes/jellyfin"; +in { + options = { + horseman.containers.jellyfin = { + enable = mkEnableOption "Watch content from 'the high seas'"; + + port = mkOption { + default = 8096; + type = types.int; + }; + + url = mkOption { + default = "https://watch.koendev.nl"; + type = types.str; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.timers."backup-jellyfin" = { + wantedBy = ["timers.target"]; + timerConfig = { + OnCalendar = "daily"; + Persistent = true; + }; + }; + + # environment.systemPackages = [pkgs.gnutar]; + # systemd.services."backup-jellyfin" = { + # script = '' + # cd ${BACKUP_DIR} + # ${pkgs.gnutar}/bin/tar -cf jellyfin-$(date +'%Y-%m-%d').tar ${DATA_DIR} + # ''; + # serviceConfig = { + # User = "root"; + # }; + # }; + + containers.jellyfin = { + autoStart = true; + privateNetwork = true; + hostAddress = "192.168.100.5"; + localAddress = "192.168.100.105"; + + bindMounts = { + "/var/lib/media" = { + hostPath = DATA_DIR; + isReadOnly = false; + }; + }; + + config = { + config, + pkgs, + ... + }: { + environment.systemPackages = with pkgs; [ + jellyfin + jellyfin-ffmpeg + jellyfin-web + ]; + services.jellyfin = { + enable = true; + }; + + services.prowlarr = { + enable = true; + openFirewall = true; + }; + + networking = { + firewall = { + enable = true; + allowedTCPPorts = [cfg.port]; + }; + useHostResolvConf = lib.mkForce false; + }; + + system.stateVersion = "23.11"; + }; + }; + }; +}