From eb8dac2fcd80f1b79225d11dea5b44f678f5a00e Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 14 Apr 2019 13:10:50 +0200 Subject: [PATCH 1/3] 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 fca4a20eee63..56c44a43c6e3 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 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 ]; +} From 7f0038344983e9a74f9b316beb939b00ed37aec8 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 14 Apr 2019 13:16:02 +0200 Subject: [PATCH 2/3] jellyfin: add minijackson to maintainers --- pkgs/servers/jellyfin/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/servers/jellyfin/default.nix b/pkgs/servers/jellyfin/default.nix index 5073519d9f31..f92314b2123a 100644 --- a/pkgs/servers/jellyfin/default.nix +++ b/pkgs/servers/jellyfin/default.nix @@ -37,6 +37,6 @@ stdenv.mkDerivation rec { description = "The Free Software Media System"; homepage = https://jellyfin.github.io/; license = licenses.gpl2; - maintainers = with maintainers; [ nyanloutre ]; + maintainers = with maintainers; [ nyanloutre minijackson ]; }; } From ab9378980a8a2bf8cffb71c62aff630e87013149 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Sun, 28 Apr 2019 11:02:32 +0200 Subject: [PATCH 3/3] nixos/jellyfin: add simple test --- nixos/tests/jellyfin.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 nixos/tests/jellyfin.nix diff --git a/nixos/tests/jellyfin.nix b/nixos/tests/jellyfin.nix new file mode 100644 index 000000000000..b60c6eb94f46 --- /dev/null +++ b/nixos/tests/jellyfin.nix @@ -0,0 +1,16 @@ +import ./make-test.nix ({ lib, ...}: + +{ + name = "jellyfin"; + meta.maintainers = with lib.maintainers; [ minijackson ]; + + machine = + { ... }: + { services.jellyfin.enable = true; }; + + testScript = '' + $machine->waitForUnit('jellyfin.service'); + $machine->waitForOpenPort('8096'); + $machine->succeed("curl --fail http://localhost:8096/"); + ''; +})