From eb8dac2fcd80f1b79225d11dea5b44f678f5a00e Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 14 Apr 2019 13:10:50 +0200 Subject: [PATCH] nixos/jellyfin: init --- nixos/modules/module-list.nix | 1 + nixos/modules/services/misc/jellyfin.nix | 60 ++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 nixos/modules/services/misc/jellyfin.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index fca4a20eee6..56c44a43c6e 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -414,6 +414,7 @@ ./services/misc/ihaskell.nix ./services/misc/irkerd.nix ./services/misc/jackett.nix + ./services/misc/jellyfin.nix ./services/misc/logkeys.nix ./services/misc/leaps.nix ./services/misc/lidarr.nix diff --git a/nixos/modules/services/misc/jellyfin.nix b/nixos/modules/services/misc/jellyfin.nix new file mode 100644 index 00000000000..7f38dd0ff23 --- /dev/null +++ b/nixos/modules/services/misc/jellyfin.nix @@ -0,0 +1,60 @@ +{ config, pkgs, lib, ... }: + +with lib; + +let + cfg = config.services.jellyfin; +in +{ + options = { + services.jellyfin = { + enable = mkEnableOption "Jellyfin Media Server"; + + user = mkOption { + type = types.str; + default = "jellyfin"; + description = "User account under which Jellyfin runs."; + }; + + group = mkOption { + type = types.str; + default = "jellyfin"; + description = "Group under which jellyfin runs."; + }; + }; + }; + + config = mkIf cfg.enable { + systemd.services.jellyfin = { + description = "Jellyfin Media Server"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + + serviceConfig = rec { + User = cfg.user; + Group = cfg.group; + StateDirectory = "jellyfin"; + CacheDirectory = "jellyfin"; + ExecStart = "${pkgs.jellyfin}/bin/jellyfin --datadir '/var/lib/${StateDirectory}' --cachedir '/var/cache/${CacheDirectory}'"; + Restart = "on-failure"; + }; + }; + + users.users = mkIf (cfg.user == "jellyfin") { + jellyfin.group = cfg.group; + }; + + users.groups = mkIf (cfg.group == "jellyfin") { + jellyfin = {}; + }; + + assertions = [ + { + assertion = !config.services.emby.enable; + message = "Emby and Jellyfin are incompatible, you cannot enable both"; + } + ]; + }; + + meta.maintainers = with lib.maintainers; [ minijackson ]; +}