services: add jellyfin

This makes use of the 'media' group, to allow using the same group for
any software that would either read or write to my media collection.
This commit is contained in:
Bruno BELANYI 2021-01-31 22:31:04 +01:00
parent c5fd1b4e63
commit 9446651944
4 changed files with 41 additions and 0 deletions

View file

@ -74,6 +74,8 @@
my.services = {
# Gitea forge
gitea.enable = true;
# Jellyfin media server
jellyfin.enable = true;
# Matrix backend and Element chat front-end
matrix.enable = true;
};

View file

@ -3,7 +3,9 @@
{
imports = [
./gitea.nix
./jellyfin.nix
./matrix.nix
./media.nix
./nginx.nix
];
}

27
services/jellyfin.nix Normal file
View file

@ -0,0 +1,27 @@
# A FLOSS media server
{ config, lib, ... }:
let
cfg = config.my.services.jellyfin;
domain = config.networking.domain;
jellyfinDomain = "jellyfin.${config.networking.domain}";
in
{
options.my.services.jellyfin = {
enable = lib.mkEnableOption "Jellyfin Media Server";
};
config = lib.mkIf cfg.enable {
services.jellyfin = {
enable = true;
group = "media";
};
# Proxy to Jellyfin
services.nginx.virtualHosts."${jellyfinDomain}" = {
forceSSL = true;
useACMEHost = "${domain}";
locations."/".proxyPass = "http://localhost:8096/";
};
};
}

10
services/media.nix Normal file
View file

@ -0,0 +1,10 @@
# Abstracting away the need for a common 'media' group
{ config, lib, ... }:
let
needed = with config.my.services;
jellyfin.enable;
in
{
config.users.groups.media = lib.mkIf needed { };
}