diff options
author | Aaron Andersen <aaron@fosslib.net> | 2019-04-28 10:21:35 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-28 10:21:35 -0400 |
commit | 3fce35fde209f8f4bcca9055a009de378c28afec (patch) | |
tree | 6d2e67df0222e77d65be2d1a482e51d89a1dddb4 /nixos/modules/services | |
parent | 59c03134dbec3eac088c5ec02d5efdd7e782d9a6 (diff) | |
parent | ab9378980a8a2bf8cffb71c62aff630e87013149 (diff) | |
download | nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.tar nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.tar.gz nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.tar.bz2 nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.tar.lz nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.tar.xz nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.tar.zst nixlib-3fce35fde209f8f4bcca9055a009de378c28afec.zip |
Merge pull request #59465 from minijackson/module-jellyfin
Diffstat (limited to 'nixos/modules/services')
-rw-r--r-- | nixos/modules/services/misc/jellyfin.nix | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/nixos/modules/services/misc/jellyfin.nix b/nixos/modules/services/misc/jellyfin.nix new file mode 100644 index 000000000000..7f38dd0ff233 --- /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 ]; +} |