summaryrefslogtreecommitdiffstats
path: root/usecases/server/jellyfin.nix
blob: 7119d38e5f019cff081486c9279f1988b2e9d750 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
inputs:

{ config, lib, pkgs, ... }:

{
  imports = [
    (inputs.nixpkgs-unstable.outPath + "/nixos/modules/services/misc/jellyfin.nix")
  ];

  disabledModules = [ "services/misc/jellyfin.nix" ];

  options = with lib; {
    services.jellyfin.allowedPaths = mkOption {
      type = with types; listOf str;
      description = ''
        A list of paths that Jellyfin is allowed to read
      '';
    };
  };

  config = {
    services.jellyfin = {
      enable = true;
      package = pkgs.unstable.jellyfin;
    };

    networking.firewall.interfaces.${config.topology.mainVpn.interfaceName}.allowedTCPPorts = [
      8096
    ];

    systemd.services.jellyfin.serviceConfig = {
      # TODO: remove when #108224 is merged

      # Allows access to drm devices for transcoding with hardware acceleration
      SupplementaryGroups = [ "video" ];
      # char-drm Allows ffmpeg to transcode with hardware acceleration
      DeviceAllow = lib.mkForce [ "char-drm rw" ];

      PrivateDevices = lib.mkForce false;

      # ================================

      # Personal:
      ProtectHome = true;
      ProtectSystem = "strict";

      BindReadOnlyPaths = [
        "/nix/store"

        "/etc/ssl/certs"
        "/etc/static/ssl/certs"

        "/etc/resolv.conf"
      ] ++ lib.optional config.hardware.opengl.enable [
        "/run/opengl-driver"
      ] ++ config.services.jellyfin.allowedPaths;

      RuntimeDirectory = "jellyfin";
      RootDirectory = "/run/jellyfin";
    };
  };
}