2021-04-24 13:43:46 +02:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchurl
|
|
|
|
, linkFarmFromDrvs
|
|
|
|
, makeWrapper
|
|
|
|
, nixosTests
|
|
|
|
, stdenv
|
|
|
|
, dotnetCorePackages
|
|
|
|
, dotnetPackages
|
|
|
|
, ffmpeg
|
|
|
|
, fontconfig
|
|
|
|
, freetype
|
|
|
|
, jellyfin-web
|
|
|
|
, sqlite
|
|
|
|
}:
|
2019-05-18 12:11:19 +02:00
|
|
|
|
|
|
|
let
|
2021-04-24 13:43:46 +02:00
|
|
|
runtimeDeps = [
|
|
|
|
ffmpeg
|
|
|
|
fontconfig
|
|
|
|
freetype
|
|
|
|
];
|
|
|
|
|
2019-05-18 12:11:19 +02:00
|
|
|
os = if stdenv.isDarwin then "osx" else "linux";
|
|
|
|
arch =
|
|
|
|
with stdenv.hostPlatform;
|
|
|
|
if isx86_32 then "x86"
|
|
|
|
else if isx86_64 then "x64"
|
|
|
|
else if isAarch32 then "arm"
|
|
|
|
else if isAarch64 then "arm64"
|
|
|
|
else lib.warn "Unsupported architecture, some image processing features might be unavailable" "unknown";
|
|
|
|
musl = lib.optionalString stdenv.hostPlatform.isMusl
|
2021-04-27 15:52:15 +02:00
|
|
|
(lib.warnIf (arch != "x64") "Some image processing features might be unavailable for non x86-64 with Musl"
|
|
|
|
"musl-");
|
2021-04-24 13:43:46 +02:00
|
|
|
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids
|
|
|
|
runtimeId = "${os}-${musl}${arch}";
|
2019-05-18 12:11:19 +02:00
|
|
|
|
2021-04-24 13:43:46 +02:00
|
|
|
dotnet-sdk = dotnetCorePackages.sdk_5_0;
|
|
|
|
dotnet-net = dotnetCorePackages.net_5_0;
|
|
|
|
dotnet-aspnetcore = dotnetCorePackages.aspnetcore_5_0;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-03-07 22:22:37 +01:00
|
|
|
pname = "jellyfin";
|
2021-05-05 08:35:53 +02:00
|
|
|
version = "10.7.5"; # ensure that jellyfin-web has matching version
|
2019-03-07 22:22:37 +01:00
|
|
|
|
2021-04-24 13:43:46 +02:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jellyfin";
|
|
|
|
repo = "jellyfin";
|
|
|
|
rev = "v${version}";
|
2021-05-05 08:35:53 +02:00
|
|
|
sha256 = "DlbNZpomNki9zrfG0C7He0Xrq79vx4Rn8ixpekvk34E=";
|
2019-03-07 22:22:37 +01:00
|
|
|
};
|
|
|
|
|
2021-03-11 23:55:04 +01:00
|
|
|
nativeBuildInputs = [
|
2021-04-24 13:43:46 +02:00
|
|
|
dotnet-sdk
|
|
|
|
dotnetPackages.Nuget
|
2019-03-07 22:22:37 +01:00
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
2021-04-24 13:43:46 +02:00
|
|
|
dotnet-aspnetcore
|
2019-03-07 22:22:37 +01:00
|
|
|
sqlite
|
|
|
|
];
|
|
|
|
|
2021-04-24 13:43:46 +02:00
|
|
|
nugetDeps = linkFarmFromDrvs "${pname}-nuget-deps" (import ./nuget-deps.nix {
|
|
|
|
fetchNuGet = { name, version, sha256 }: fetchurl {
|
|
|
|
name = "nuget-${name}-${version}.nupkg";
|
|
|
|
url = "https://www.nuget.org/api/v2/package/${name}/${version}";
|
|
|
|
inherit sha256;
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
configurePhase = ''
|
|
|
|
runHook preConfigure
|
|
|
|
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
|
|
|
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
|
|
|
export DOTNET_NOLOGO=1
|
|
|
|
|
|
|
|
nuget sources Add -Name nixos -Source "$PWD/nixos"
|
|
|
|
nuget init "$nugetDeps" "$PWD/nixos"
|
|
|
|
|
|
|
|
# FIXME: https://github.com/NuGet/Home/issues/4413
|
|
|
|
mkdir -p $HOME/.nuget/NuGet
|
|
|
|
cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet
|
|
|
|
|
|
|
|
runHook postConfigure
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
dotnet publish Jellyfin.Server \
|
|
|
|
--configuration Release \
|
|
|
|
--runtime ${runtimeId} \
|
|
|
|
--no-self-contained \
|
|
|
|
--output $out/opt/jellyfin
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2019-03-07 22:22:37 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
2021-03-11 23:55:04 +01:00
|
|
|
runHook preInstall
|
2021-04-24 13:43:46 +02:00
|
|
|
|
|
|
|
makeWrapper ${dotnet-aspnetcore}/bin/dotnet $out/bin/jellyfin \
|
|
|
|
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
|
|
|
|
--add-flags "$out/opt/jellyfin/jellyfin.dll" \
|
|
|
|
--add-flags "--ffmpeg ${ffmpeg}/bin/ffmpeg" \
|
|
|
|
--add-flags "--webdir ${jellyfin-web}/share/jellyfin-web"
|
|
|
|
|
2021-03-11 23:55:04 +01:00
|
|
|
runHook postInstall
|
2019-03-07 22:22:37 +01:00
|
|
|
'';
|
|
|
|
|
2020-04-13 12:47:26 +02:00
|
|
|
passthru.tests = {
|
|
|
|
smoke-test = nixosTests.jellyfin;
|
|
|
|
};
|
|
|
|
|
2021-04-24 13:43:46 +02:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
|
|
|
meta = with lib; {
|
2019-03-07 22:22:37 +01:00
|
|
|
description = "The Free Software Media System";
|
2020-08-15 06:31:02 +02:00
|
|
|
homepage = "https://jellyfin.org/";
|
2021-03-11 23:55:04 +01:00
|
|
|
# https://github.com/jellyfin/jellyfin/issues/610#issuecomment-537625510
|
|
|
|
license = licenses.gpl2Plus;
|
2021-04-24 13:43:46 +02:00
|
|
|
maintainers = with maintainers; [ nyanloutre minijackson purcell jojosch ];
|
2019-03-07 22:22:37 +01:00
|
|
|
};
|
|
|
|
}
|