Self-Hosting Jellyfin on NixOS: Declarative Media Streaming That Just Works

Self-Hosting Jellyfin on NixOS: Declarative Media Streaming That Just Works

Table of Contents

Tired of juggling multiple streaming subscriptions that eat into your monthly budget? What if you could build your own personal Netflix, complete with a media library you fully control, and do it all with configurations you can version control and reproduce anywhere? That’s the power of self-hosting Jellyfin on NixOS.

Jellyfin* is a free, open-source media server that lets you organize, stream, and share your movies, TV shows, music, and photos across devices. Pair it with NixOS* - a Linux distribution built around declarative, reproducible system configuration - and you get a setup that’s both powerful and reliable. NixOS’s atomic updates mean you can roll back if something breaks, and its declarative nature keeps your setup consistent across machines.

In this tutorial, we’ll walk through setting up Jellyfin on NixOS from scratch. By the end, you’ll have a working media server with remote access, hardware acceleration, and a configuration you can keep in Git. We assume basic Nix knowledge and keep things straightforward, with the common pitfalls flagged along the way.

What You’ll Need

  • A NixOS server running NixOS 26.05 or newer (the examples use current options; on 25.11 everything here works except the hardwareAcceleration block, which is noted below)
  • Basic familiarity with the Nix language
  • At least 20 GB of free disk space for your media library
  • Your media files (movies, TV shows, etc.) stored on the server
  • (Optional) A domain name for easy remote access

Part 1: Why NixOS for Jellyfin

Why does NixOS make self-hosting Jellyfin so much better than a traditional Linux setup? It comes down to declarative configuration.

On a traditional distribution, you install and configure services with a series of commands. If something breaks, or you want the same setup on another machine, you repeat the process by hand. NixOS flips this: you describe the system’s desired state in code. Your configuration.nix declares which services run, how they’re configured, and which packages are installed.

For Jellyfin, that means:

  • Atomic rollbacks: if an update breaks something, you can revert to a working state.
  • Reproducibility: the same config produces the same setup on any NixOS machine.
  • Version control: keep your config in Git and track every change.

The strategy here is simple: add Jellyfin to configuration.nix, enable it declaratively, and build from there. No manual service starts, no hand-edited config files.

Part 2: Basic Jellyfin Configuration

Open your configuration.nix (usually /etc/nixos/configuration.nix) and add:

services.jellyfin = {
  enable = true;
  openFirewall = true;
};
  • enable = true; installs and runs the Jellyfin service.
  • openFirewall = true; opens the default Jellyfin ports in the firewall (8096 for HTTP, 8920 for HTTPS, plus the client-discovery UDP ports) so other devices on your network can reach it.

Apply the configuration:

sudo nixos-rebuild switch

The first rebuild takes a few minutes while Nix downloads Jellyfin. Verify it’s running:

sudo systemctl status jellyfin

You should see “active (running)”. Open a browser and go to http://your-server-ip:8096 (replace with your NixOS machine’s IP). The Jellyfin setup wizard greets you: create an admin account and you’re in.

The most common stumble at this point is the firewall: if the page won’t load from another device, check that openFirewall = true; made it into the config you actually rebuilt.

Part 3: Hardware Acceleration and Data Directories

With the basics running, two options are worth knowing. Update your configuration.nix:

services.jellyfin = {
  enable = true;
  openFirewall = true;
  dataDir = "/var/lib/jellyfin";  # this is the default; set it to move metadata to another drive
};

For hardware-accelerated transcoding on an Intel or AMD GPU, NixOS 26.05 and newer have a dedicated option block (on 25.11, enable transcoding in the Jellyfin dashboard under Playback instead):

hardware.graphics.enable = true;

services.jellyfin = {
  enable = true;
  openFirewall = true;
  hardwareAcceleration = {
    enable = true;
    device = "/dev/dri/renderD128";  # check /dev/dri/ on your machine
    type = "vaapi";                  # "qsv" for newer Intel chips
  };
};

This writes Jellyfin’s encoding configuration for you, so transcoding uses the GPU instead of burning CPU. NVIDIA users can set type = "nvenc"; with the NVIDIA driver configured.

One thing you will not find is a services.jellyfin.port option: Jellyfin owns its port. Change it in the Jellyfin dashboard under Networking, and remember that openFirewall only opens the default ports, so open the new one explicitly if you change it.

Rebuild with sudo nixos-rebuild switch after each change. Testing is safe: you can always roll back.

Part 4: Media Library Setup

Create a directory structure for your media:

sudo mkdir -p /media/movies /media/tv-shows /media/music
sudo chown -R jellyfin:jellyfin /media

That ownership step matters: Jellyfin runs as the jellyfin user, and if it can’t read your files you get empty libraries with no obvious error. This is the single most common Jellyfin-on-NixOS gotcha.

Copy your media in. For the best metadata matches, follow Jellyfin’s naming conventions:

  • Movies: Movie Title (Year).mp4
  • TV shows: Show Name S01E01.mp4

In the Jellyfin web interface, go to Dashboard > Libraries, add your folders, pick the content type, and let the scan run. Large libraries take a while.

Part 5: Remote Access with Nginx

To reach Jellyfin from outside your home network, put Nginx in front with a free Let’s Encrypt certificate:

services.nginx = {
  enable = true;
  recommendedTlsSettings = true;
  recommendedOptimisation = true;
  recommendedGzipSettings = true;
  virtualHosts."jellyfin.yourdomain.com" = {
    enableACME = true;
    forceSSL = true;
    locations."/" = {
      proxyPass = "http://127.0.0.1:8096";
      proxyWebsockets = true;
    };
  };
};

networking.firewall.allowedTCPPorts = [ 80 443 ];

This gives you Nginx as a reverse proxy with automatic HTTPS via ACME. Ports 80 and 443 need to be open (80 is how Let’s Encrypt verifies your domain), and your domain’s DNS needs to point at your server. The proxyWebsockets line matters: Jellyfin’s web clients use websockets, and without it some playback features silently misbehave.

Rebuild, and you have secure remote access.

Part 6: Version Control and Rollbacks

Now put NixOS’s strengths to work. Store your config in Git:

cd /etc/nixos
sudo git init
sudo git add configuration.nix
sudo git commit -m "Add Jellyfin server configuration"

Test changes without applying them:

sudo nixos-rebuild build   # builds without switching
sudo nixos-rebuild switch  # applies

If something breaks:

sudo nixos-rebuild switch --rollback

To reproduce the setup on another machine, copy the config and rebuild. No more “it works on my machine.”

Part 7: Docker Alternative (Bonus)

Prefer containers? NixOS runs them declaratively too:

virtualisation.oci-containers.containers.jellyfin = {
  image = "jellyfin/jellyfin:latest";
  ports = [ "8096:8096" ];
  volumes = [
    "/media:/media"
    "/var/lib/jellyfin:/config"
  ];
};

Same permission rule applies: the container’s Jellyfin process must be able to read /media and write /config. (If you use the LinuxServer.io image instead, its PUID/PGID environment variables exist for exactly this; the official image doesn’t use them.)

Troubleshooting

  • Empty libraries: permissions. Make sure the jellyfin user can read your media: sudo chown -R jellyfin:jellyfin /media.
  • Rebuild fails: check for typos with sudo nixos-rebuild build before switching.
  • Service won’t start: read the logs with sudo journalctl -u jellyfin.
  • Firewall surprises: firewall rules are declarative on NixOS. If you change Jellyfin’s port in the dashboard, open the new port yourself.
  • Updates work differently: packages are immutable; updates come through rebuilds, not apt or yum.

If all else fails, the NixOS community forums are genuinely helpful.

Conclusion

Self-hosting Jellyfin on NixOS isn’t just about saving money: it’s about control and reliability. The declarative approach eliminates configuration drift and makes the setup reproducible. Once Jellyfin is running, adding more services (a *arr stack, a download client, other media tools) is just more config.

Next steps: explore Jellyfin’s plugins, set up automated backups of your metadata, or look at Sonarr and Radarr for media management. Questions about a tricky setup? Send us a message - tricky self-hosting setups are what we do.

Related Posts

Before you choose a reporting tool

A reporting project starts with a question, not a dashboard list. What do you need to know, where is the data and who uses the answer?

Read More

Protect your family from AI voice-clone scams

A familiar voice is no longer enough. Set a family safe word, verify urgent requests with a callback, and keep account codes to yourself.

Read More

Getting Started with Home Assistant: Automate Your Smart Home Without Big Tech

Escape the Google and Apple ecosystems. Here's how to set up Home Assistant and take back control of your smart home from Big Tech.

Read More

* Links marked with an asterisk go to our FOSS Index, not the project’s own website. Each entry includes official project links and other useful references, including support options where available.