nixos/jellyfin: init

This commit is contained in:
Minijackson 2019-04-14 13:10:50 +02:00
parent a210440959
commit eb8dac2fcd
No known key found for this signature in database
GPG Key ID: FEA888C9F5D64F62
2 changed files with 61 additions and 0 deletions

View File

@ -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

View File

@ -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 ];
}