From 4bc5d57fa69a393877e7019d7673ceb33c3ab4b4 Mon Sep 17 00:00:00 2001 From: Simon Gardling Date: Fri, 17 Apr 2026 22:08:29 -0400 Subject: [PATCH] jellyfin: restartTriggers on webhook plugin so install runs at activation The jellyfin-webhook-install oneshot has 'wantedBy = jellyfin.service', which only runs it when jellyfin (re)starts. On first rollout to a host where jellyfin is already running, the unit gets added but never fires, leaving the Webhook plugin files absent -- jellyfin-webhook-configure then gets 404 from /Plugins/$GUID/Configuration and deploy-rs rolls back. Pinning jellyfin.restartTriggers to the plugin package + install script forces a restart whenever either derivation changes, which pulls install in via the existing before/wantedBy chain. --- .../jellyfin/jellyfin-qbittorrent-monitor.nix | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/services/jellyfin/jellyfin-qbittorrent-monitor.nix b/services/jellyfin/jellyfin-qbittorrent-monitor.nix index 9b800d1..92e3341 100644 --- a/services/jellyfin/jellyfin-qbittorrent-monitor.nix +++ b/services/jellyfin/jellyfin-qbittorrent-monitor.nix @@ -13,7 +13,13 @@ in lib.mkIf config.services.jellyfin.enable { # Materialise the Jellyfin Webhook plugin into Jellyfin's plugins dir before # Jellyfin starts. Jellyfin rewrites meta.json at runtime, so a read-only - # nix-store symlink would EACCES — we copy instead. + # nix-store symlink would EACCES -- we copy instead. + # + # `wantedBy = [ "jellyfin.service" ]` alone is insufficient on initial rollout: + # if jellyfin is already running at activation time, systemd won't start the + # oneshot until the next jellyfin restart. `restartTriggers` on jellyfin pinned + # to the plugin package + install script forces that restart whenever either + # changes, which invokes this unit via the `before`/`wantedBy` chain. systemd.services.jellyfin-webhook-install = { before = [ "jellyfin.service" ]; wantedBy = [ "jellyfin.service" ]; @@ -28,6 +34,13 @@ lib.mkIf config.services.jellyfin.enable { }; }; + systemd.services.jellyfin.restartTriggers = [ + webhookPlugin.package + (webhookPlugin.mkInstallScript { + pluginsDir = "${config.services.jellyfin.dataDir}/plugins"; + }) + ]; + # After Jellyfin starts, POST the plugin configuration so the webhook # targets the monitor's receiver. Idempotent; runs on every boot. systemd.services.jellyfin-webhook-configure = {