From 6a4b07f036e811f3f9d79319c46b7597daa94ae4 Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 29 Aug 2023 00:23:47 +0200 Subject: [PATCH 1/2] cluster/services/warehouse: workaround for ffmpeg config bug --- cluster/services/warehouse/host.nix | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/cluster/services/warehouse/host.nix b/cluster/services/warehouse/host.nix index de23352..91dcd7a 100644 --- a/cluster/services/warehouse/host.nix +++ b/cluster/services/warehouse/host.nix @@ -24,13 +24,17 @@ with tools.nginx; enable = true; package = pkgs.intel-media-driver; }; - systemd.services.jellyfin.serviceConfig = { - # allow access to GPUs for hardware transcoding - DeviceAllow = lib.mkForce "char-drm"; - BindPaths = lib.mkForce "/dev/dri"; - # to allow restarting from web ui - Restart = lib.mkForce "always"; + systemd.services.jellyfin = { + # if EncoderAppPath is manually set in the web UI, it can never be updated through --ffmpeg + preStart = "test ! -e /var/lib/jellyfin/config/encoding.xml || sed -i '//d' /var/lib/jellyfin/config/encoding.xml"; + serviceConfig = { + # allow access to GPUs for hardware transcoding + DeviceAllow = lib.mkForce "char-drm"; + BindPaths = lib.mkForce "/dev/dri"; + # to allow restarting from web ui + Restart = lib.mkForce "always"; - Slice = "mediaplayback.slice"; + Slice = "mediaplayback.slice"; + }; }; } -- 2.47.0 From fb7e1163a0bd58d744d2300df4f0a43f8ddbe40f Mon Sep 17 00:00:00 2001 From: Max Date: Tue, 29 Aug 2023 00:24:28 +0200 Subject: [PATCH 2/2] checks/jellyfin-stateless: init --- packages/checks/default.nix | 15 ++++++++++-- packages/checks/jellyfin-stateless.nix | 34 ++++++++++++++++++++++++++ packages/system-filter.nix | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 packages/checks/jellyfin-stateless.nix diff --git a/packages/checks/default.nix b/packages/checks/default.nix index 02b9853..9d29bf2 100644 --- a/packages/checks/default.nix +++ b/packages/checks/default.nix @@ -1,8 +1,19 @@ -{ self, ... }: +{ lib, self, ... }: { - perSystem = { filters, pkgs, self', ... }: { + perSystem = { filters, pkgs, self', ... }: let + fakeCluster = import ../../cluster { + inherit lib; + hostName = throw "not available in test environment"; + depot = throw "not available in test environment"; + }; + in { checks = filters.doFilter filters.checks { + jellyfin-stateless = pkgs.callPackage ./jellyfin-stateless.nix { + inherit (self'.packages) jellyfin; + inherit fakeCluster; + }; + keycloak = pkgs.callPackage ./keycloak-custom-jre.nix { jre = self'.packages.jre17_standard; }; diff --git a/packages/checks/jellyfin-stateless.nix b/packages/checks/jellyfin-stateless.nix new file mode 100644 index 0000000..c22e66e --- /dev/null +++ b/packages/checks/jellyfin-stateless.nix @@ -0,0 +1,34 @@ +{ nixosTest, fakeCluster, jellyfin }: + +nixosTest { + name = "jellyfin-stateless"; + nodes = { + machine = { + imports = fakeCluster.config.services.warehouse.nixos.host; + + _module.args.depot.packages.jellyfin = jellyfin; + }; + }; + testScript = /*python*/ '' + def start_jf(): + machine.succeed("systemctl start jellyfin.service") + machine.wait_for_unit("jellyfin.service") + machine.wait_for_open_port(8096) + machine.wait_until_succeeds("curl --fail http://127.0.0.1:8096") + + def stop_jf(): + machine.succeed("systemctl stop jellyfin.service") + + machine.wait_for_unit("jellyfin.service") + + start_jf() + machine.succeed("sed -i 's,EncoderAppPathDisplay,EncoderAppPath,g' /var/lib/jellyfin/config/encoding.xml") + machine.succeed("sed -i 's,.*,/FAKE/bin/ffmpeg,g' /var/lib/jellyfin/config/encoding.xml") + stop_jf() + start_jf() + + with subtest("should reset to real ffmpeg"): + machine.fail("grep -q '/FAKE/bin/ffmpeg' /var/lib/jellyfin/config/encoding.xml") + machine.succeed("grep -q '/nix/store/.*/bin/ffmpeg' /var/lib/jellyfin/config/encoding.xml") + ''; +} diff --git a/packages/system-filter.nix b/packages/system-filter.nix index cd519c6..f2f0f82 100644 --- a/packages/system-filter.nix +++ b/packages/system-filter.nix @@ -12,6 +12,7 @@ tempo = [ "x86_64-linux" ]; }; checks = { + jellyfin-stateless = [ "x86_64-linux" ]; keycloak = [ "x86_64-linux" ]; patroni = [ "x86_64-linux" ]; searxng = [ "x86_64-linux" ]; -- 2.47.0