2019-04-14 12:10:50 +01:00
|
|
|
{ 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.";
|
|
|
|
};
|
|
|
|
|
2020-08-16 16:41:41 +01:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
example = literalExample "pkgs.jellyfin";
|
|
|
|
description = ''
|
|
|
|
Jellyfin package to use.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-04-14 12:10:50 +01:00
|
|
|
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";
|
2020-08-16 16:41:41 +01:00
|
|
|
ExecStart = "${cfg.package}/bin/jellyfin --datadir '/var/lib/${StateDirectory}' --cachedir '/var/cache/${CacheDirectory}'";
|
2019-04-14 12:10:50 +01:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-08-16 16:41:41 +01:00
|
|
|
services.jellyfin.package = mkDefault (
|
|
|
|
if versionAtLeast config.system.stateVersion "20.09" then pkgs.jellyfin
|
|
|
|
else pkgs.jellyfin_10_5
|
|
|
|
);
|
|
|
|
|
2019-04-14 12:10:50 +01:00
|
|
|
users.users = mkIf (cfg.user == "jellyfin") {
|
2019-10-12 21:25:28 +01:00
|
|
|
jellyfin = {
|
|
|
|
group = cfg.group;
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
2019-04-14 12:10:50 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
users.groups = mkIf (cfg.group == "jellyfin") {
|
|
|
|
jellyfin = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ minijackson ];
|
|
|
|
}
|