Movies, shows, and music tend to fall under the broad category of “media”. This means that there exist solutions to self-host an entire suite for all “media”, so there is no need to pay seperate subscriptions to services such as Netflix and/or Spotify.
Self-hosted means BYOM (Bring Your Own Media).
This will not buy you movies/tv shows/music.
On a discussion on the subject, read this article
I am not taking any ethical stance on piracy; I am taking an ethical stance on ownership.
We will be using Jellyfin, which is a free and open-source software for serving media libraries, effectively replacing Netflix (albeit with a clankier UI) and spotify, with dedicated third-party clients.
specs #
Whilst serving videos, the server needs to parse the bits; the higher the resolution, the higher the useage.
When idling, jellyfin takes 273M of RAM on my system.
installation #
Create a jellyfin folder and a default.nix file inside it, at the place where you have the rest of your nixos configuration
$ mkdir jellyfin && touch jellyfin/default.nix(or use the file explorer of your choice)
nix declaration #
Open jellyfin/default.nix in any text editor, and copy the following
{ config, pkgs, lib, ...}:
{
environment.systemPackages = with pkgs; [
jellyfin
jellyfin-web
jellyfin-ffmpeg
logrotate
];
services = {
jellyfin = {
enable = true;
};
logrotate.enable = true;
nginx = {
virtualHosts."media.<YOUR-DOMAIN" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://127.0.0.1:8096";
proxyWebsockets = true;
};
};
};
};
}Then to enable it, just include it in the server config file:
imports = [
# ... other services
./jellyfin
# ... other services
];and you’re done.
Let’s break the config file down.
explanation #
- First, we declare the packages that we will use. We install them as systemPackages, because jellyfin is packaged in a weird manner.
- Then, we declare the
jellyfinservice as enabled. - We enable logrotate, which helps clean logs and keeps them in a manageable size (otherwise jellyfin tends to fill the logs and bloat the system).
- We set up nginx to set up a reverse proxy at
media.<YOUR-DOMAIN>, so that jellyfin is only acessible via the reverse proxy.
The nix service of Jellyfin doesn’t allow us to customize the port, so the default one (
8096) has to be used.
More information can be found at the wiki, but it can be opaque. Specifically it has info concerning mounting external drives (from a NAS potentially), which is not covered here.
More options can be found here.
further setup #
Once the service is up and running, go to localhost:8096, or media.<YOUR-DOMAIN>, or whatever domain you set it to.
You must set up an administrator account. This can either be a completely seperate account to your own, or it could be your own account.
You must also point and set up the different libraries (and types of libraries) you want to host, like Movies/TV Shows/Music, etc. You can have multiple of each type. I have three for Music, two for TV Shows, and one for Movies, because I share this instance with other family members.
Playlists are public in each library. You might want to make a Music library per user.
service backups #
Jellyfin simply serves media files, and fetches and displays metadata from within the media folders you provide. Just keep a backup of those folders. To keep a copy of the exact jellyfin setup and configuration you may do on top of the nix service, just keep a copy of /var/lib/jellyfin.