From 22da56ff4a0417cc057b77b6f023b545e86b1ac4 Mon Sep 17 00:00:00 2001 From: Scott Scoble Date: Fri, 15 May 2026 21:55:10 -0700 Subject: [PATCH] feat: add NixOS module for Jellyfin integration Add nixosModules.default with: - services.jellyfin-lessons.enable toggle - Configurable dataDir and adminPort options - Plugin DLL auto-copy to Jellyfin plugins dir - Admin UI as a user systemd service The projectFile path was already correct (Jellyfin.Plugin.Lessons.csproj). nix flake check passes. --- flake.nix | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/flake.nix b/flake.nix index 2645a68..114ed09 100644 --- a/flake.nix +++ b/flake.nix @@ -68,5 +68,50 @@ ) { }; } ); + + nixosModules.default = + { config, lib, pkgs, ... }: + let + cfg = config.services.jellyfin-lessons; + in + { + options.services.jellyfin-lessons = { + enable = lib.mkEnableOption "Jellyfin Lessons plugin"; + dataDir = lib.mkOption { + type = lib.types.str; + default = "/var/lib/jellyfin-lessons"; + description = "Directory for lessons database"; + }; + adminPort = lib.mkOption { + type = lib.types.port; + default = 3099; + description = "Port for admin UI"; + }; + }; + + config = lib.mkIf cfg.enable { + # Copy plugin DLL to Jellyfin plugins directory on jellyfin preStart + systemd.services.jellyfin = { + preStart = let + pluginPkg = self.packages.${pkgs.system}.default; + in '' + mkdir -p /var/lib/jellyfin/plugins/Lessons + cp -f ${pluginPkg}/lib/jellyfin-lessons/*.dll /var/lib/jellyfin/plugins/Lessons/ + ''; + }; + + # Admin UI as a user systemd service + systemd.user.services.jellyfin-lessons-admin = { + description = "Jellyfin Lessons Admin UI"; + after = [ "network.target" ]; + wantedBy = [ "default.target" ]; + serviceConfig = { + ExecStart = "${pkgs.nodejs}/bin/node ${self}/admin-ui/server.js"; + Restart = "on-failure"; + Environment = "PORT=${toString cfg.adminPort}"; + }; + }; + }; + }; }; } -- 2.49.1