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.
117 lines
3.3 KiB
Nix
117 lines
3.3 KiB
Nix
{
|
|
description = "Jellyfin Lessons — a Jellyfin plugin";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
};
|
|
|
|
outputs =
|
|
{ self, nixpkgs }:
|
|
let
|
|
forAllSystems =
|
|
fn: nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed fn;
|
|
in
|
|
{
|
|
devShells = forAllSystems (
|
|
system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
default = pkgs.mkShell {
|
|
packages = [
|
|
pkgs.dotnetCorePackages.sdk_9_0
|
|
pkgs.typst
|
|
pkgs.nodejs
|
|
];
|
|
|
|
shellHook = ''
|
|
echo "jellyfin-lessons dev shell"
|
|
echo " dotnet: $(dotnet --version)"
|
|
echo " typst: $(typst --version)"
|
|
echo " node: $(node --version)"
|
|
'';
|
|
};
|
|
}
|
|
);
|
|
|
|
packages = forAllSystems (
|
|
system:
|
|
let
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
|
in
|
|
{
|
|
default = pkgs.callPackage (
|
|
{
|
|
buildDotnetModule,
|
|
dotnetCorePackages,
|
|
lib,
|
|
}:
|
|
buildDotnetModule {
|
|
pname = "jellyfin-lessons";
|
|
version = "0.1.0";
|
|
|
|
src = self;
|
|
|
|
projectFile = "plugin/Jellyfin.Plugin.Lessons.csproj";
|
|
nugetDeps = ./deps.json;
|
|
|
|
dotnet-sdk = dotnetCorePackages.sdk_9_0;
|
|
dotnet-runtime = dotnetCorePackages.aspnetcore_9_0;
|
|
|
|
meta = {
|
|
description = "Jellyfin Lessons plugin";
|
|
license = lib.licenses.mit;
|
|
platforms = lib.platforms.all;
|
|
};
|
|
}
|
|
) { };
|
|
}
|
|
);
|
|
|
|
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}";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|