Nixconfigs/modules/servermodules/jellyfin/jellyfin.nix
2025-10-12 17:39:55 +02:00

60 lines
1.5 KiB
Nix

{
pkgs,
config,
exporter-pkg,
...
}:
{
environment.systemPackages = [
pkgs.jellyfin
pkgs.jellyfin-web
pkgs.jellyfin-ffmpeg
];
services.jellyfin = {
enable = true;
configDir = "/jellyfin/config";
dataDir = "/jellyfin/data";
};
age.secrets.jellyfin-key = {
file = ./secrets/jellyfin-key;
owner = "jellyfin";
};
# Define the systemd service
systemd.services.jellyfin-exporter = {
description = "Jellyfin Exporter for Prometheus";
wantedBy = [ "multi-user.target" ];
after = [
"network-online.target"
"run-agenix.d.mount"
]; # Should start after network is up
wants = [
"network-online.target"
"run-agenix.d.mount"
]; # Should start after network is up
serviceConfig = {
# The command to start the exporter
# You MUST replace the placeholders below with your actual data
ExecStart = ''
/bin/sh -c "${exporter-pkg}/bin/jellyfin_exporter \
--jellyfin.address=http://localhost:8096 \
--jellyfin.token=$(cat ${config.age.secrets.jellyfin-key.path})"
'';
# Run the service as the user we created
User = "jellyfin";
# Automatically restart the service if it fails
Restart = "on-failure";
RestartSec = "5s";
};
};
systemd.tmpfiles.rules = [
"L+ /data/movies - - - - /mnt/volume-hel1-1/movies"
"L+ /data/series - - - - /mnt/volume-hel1-1/series"
];
}