jellyfin: build from source
This commit is contained in:
parent
7ab48fedf6
commit
a7ccfa062c
@ -1,7 +1,26 @@
|
|||||||
{ stdenv, lib, fetchurl, unzip, sqlite, makeWrapper, dotnetCorePackages, ffmpeg,
|
{ lib
|
||||||
fontconfig, freetype, nixosTests }:
|
, fetchFromGitHub
|
||||||
|
, fetchurl
|
||||||
|
, linkFarmFromDrvs
|
||||||
|
, makeWrapper
|
||||||
|
, nixosTests
|
||||||
|
, stdenv
|
||||||
|
, dotnetCorePackages
|
||||||
|
, dotnetPackages
|
||||||
|
, ffmpeg
|
||||||
|
, fontconfig
|
||||||
|
, freetype
|
||||||
|
, jellyfin-web
|
||||||
|
, sqlite
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
runtimeDeps = [
|
||||||
|
ffmpeg
|
||||||
|
fontconfig
|
||||||
|
freetype
|
||||||
|
];
|
||||||
|
|
||||||
os = if stdenv.isDarwin then "osx" else "linux";
|
os = if stdenv.isDarwin then "osx" else "linux";
|
||||||
arch =
|
arch =
|
||||||
with stdenv.hostPlatform;
|
with stdenv.hostPlatform;
|
||||||
@ -13,39 +32,82 @@ let
|
|||||||
musl = lib.optionalString stdenv.hostPlatform.isMusl
|
musl = lib.optionalString stdenv.hostPlatform.isMusl
|
||||||
(lib.warnIf (arch != "x64") "Some image processing features might be unavailable for non x86-64 with Musl"
|
(lib.warnIf (arch != "x64") "Some image processing features might be unavailable for non x86-64 with Musl"
|
||||||
"musl-");
|
"musl-");
|
||||||
runtimeDir = "${os}-${musl}${arch}";
|
# https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids
|
||||||
|
runtimeId = "${os}-${musl}${arch}";
|
||||||
|
|
||||||
in stdenv.mkDerivation rec {
|
dotnet-sdk = dotnetCorePackages.sdk_5_0;
|
||||||
|
dotnet-net = dotnetCorePackages.net_5_0;
|
||||||
|
dotnet-aspnetcore = dotnetCorePackages.aspnetcore_5_0;
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
pname = "jellyfin";
|
pname = "jellyfin";
|
||||||
version = "10.7.2";
|
version = "10.7.2"; # ensure that jellyfin-web has matching version
|
||||||
|
|
||||||
# Impossible to build anything offline with dotnet
|
src = fetchFromGitHub {
|
||||||
src = fetchurl {
|
owner = "jellyfin";
|
||||||
url = "https://repo.jellyfin.org/releases/server/portable/versions/stable/combined/${version}/jellyfin_${version}.tar.gz";
|
repo = "jellyfin";
|
||||||
sha256 = "sha256-l2tQmKez06cekq/QLper+OrcSU/0lWpZ85xY2wZcK1s=";
|
rev = "v${version}";
|
||||||
|
sha256 = "Sth1LwU8KZjvz+dVgSzvtmhm+usulCYq/W8tnqH+fd4=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
unzip
|
dotnet-sdk
|
||||||
|
dotnetPackages.Nuget
|
||||||
makeWrapper
|
makeWrapper
|
||||||
];
|
];
|
||||||
|
|
||||||
propagatedBuildInputs = [
|
propagatedBuildInputs = [
|
||||||
dotnetCorePackages.aspnetcore_5_0
|
dotnet-aspnetcore
|
||||||
sqlite
|
sqlite
|
||||||
];
|
];
|
||||||
|
|
||||||
preferLocalBuild = true;
|
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
|
||||||
|
'';
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
install -dm 755 "$out/opt/jellyfin"
|
|
||||||
cp -r * "$out/opt/jellyfin"
|
makeWrapper ${dotnet-aspnetcore}/bin/dotnet $out/bin/jellyfin \
|
||||||
makeWrapper "${dotnetCorePackages.aspnetcore_5_0}/bin/dotnet" $out/bin/jellyfin \
|
--suffix LD_LIBRARY_PATH : "${lib.makeLibraryPath runtimeDeps}" \
|
||||||
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [
|
--add-flags "$out/opt/jellyfin/jellyfin.dll" \
|
||||||
sqlite fontconfig freetype stdenv.cc.cc.lib
|
--add-flags "--ffmpeg ${ffmpeg}/bin/ffmpeg" \
|
||||||
]}:$out/opt/jellyfin/runtimes/${runtimeDir}/native/" \
|
--add-flags "--webdir ${jellyfin-web}/share/jellyfin-web"
|
||||||
--add-flags "$out/opt/jellyfin/jellyfin.dll --ffmpeg ${ffmpeg}/bin/ffmpeg"
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
@ -53,11 +115,13 @@ in stdenv.mkDerivation rec {
|
|||||||
smoke-test = nixosTests.jellyfin;
|
smoke-test = nixosTests.jellyfin;
|
||||||
};
|
};
|
||||||
|
|
||||||
meta = with lib; {
|
passthru.updateScript = ./update.sh;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
description = "The Free Software Media System";
|
description = "The Free Software Media System";
|
||||||
homepage = "https://jellyfin.org/";
|
homepage = "https://jellyfin.org/";
|
||||||
# https://github.com/jellyfin/jellyfin/issues/610#issuecomment-537625510
|
# https://github.com/jellyfin/jellyfin/issues/610#issuecomment-537625510
|
||||||
license = licenses.gpl2Plus;
|
license = licenses.gpl2Plus;
|
||||||
maintainers = with maintainers; [ nyanloutre minijackson purcell ];
|
maintainers = with maintainers; [ nyanloutre minijackson purcell jojosch ];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
2268
pkgs/servers/jellyfin/nuget-deps.nix
Normal file
2268
pkgs/servers/jellyfin/nuget-deps.nix
Normal file
File diff suppressed because it is too large
Load Diff
52
pkgs/servers/jellyfin/update.sh
Executable file
52
pkgs/servers/jellyfin/update.sh
Executable file
@ -0,0 +1,52 @@
|
|||||||
|
#!/usr/bin/env nix-shell
|
||||||
|
#!nix-shell -i bash -p curl jq common-updater-scripts dotnetCorePackages.sdk_5_0 gnused nix coreutils findutils
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
export DOTNET_NOLOGO=1
|
||||||
|
|
||||||
|
latestVersion="$(curl -s "https://api.github.com/repos/jellyfin/jellyfin/releases?per_page=1" | jq -r ".[0].tag_name" | sed 's/^v//')"
|
||||||
|
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; jellyfin.version or (lib.getVersion jellyfin)" | tr -d '"')
|
||||||
|
|
||||||
|
if [[ "$currentVersion" == "$latestVersion" ]]; then
|
||||||
|
echo "jellyfin is up-to-date: $currentVersion"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
pushd "$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
nugetDepsFile=$(realpath ./nuget-deps.nix)
|
||||||
|
popd
|
||||||
|
|
||||||
|
update-source-version jellyfin "$latestVersion"
|
||||||
|
|
||||||
|
store_src="$(nix-build . -A jellyfin.src --no-out-link)"
|
||||||
|
src="$(mktemp -d /tmp/jellyfin-src.XXX)"
|
||||||
|
echo "Temp src dir: $src"
|
||||||
|
cp -rT "$store_src" "$src"
|
||||||
|
chmod -R +w "$src"
|
||||||
|
|
||||||
|
pushd "$src"
|
||||||
|
|
||||||
|
mkdir ./nuget_tmp.packages
|
||||||
|
dotnet restore Jellyfin.Server --packages ./nuget_tmp.packages --runtime linux-x64
|
||||||
|
|
||||||
|
echo "# This file has been generated by the jellyfin updateScript. Do not edit!" >"$nugetDepsFile"
|
||||||
|
echo "{ fetchNuGet }: [" >>"$nugetDepsFile"
|
||||||
|
while read -r pkg_spec; do
|
||||||
|
{ read -r pkg_name; read -r pkg_version; } < <(
|
||||||
|
# Build version part should be ignored: `3.0.0-beta2.20059.3+77df2220` -> `3.0.0-beta2.20059.3`
|
||||||
|
sed -nE 's/.*<id>([^<]*).*/\1/p; s/.*<version>([^<+]*).*/\1/p' "$pkg_spec")
|
||||||
|
pkg_sha256="$(nix-hash --type sha256 --flat --base32 "$(dirname "$pkg_spec")"/*.nupkg)"
|
||||||
|
cat >>"$nugetDepsFile" <<EOF
|
||||||
|
(fetchNuGet {
|
||||||
|
name = "$pkg_name";
|
||||||
|
version = "$pkg_version";
|
||||||
|
sha256 = "$pkg_sha256";
|
||||||
|
})
|
||||||
|
EOF
|
||||||
|
done < <(find ./nuget_tmp.packages -name '*.nuspec' | sort)
|
||||||
|
echo "]" >>"$nugetDepsFile"
|
||||||
|
|
||||||
|
popd
|
||||||
|
rm -r "$src"
|
Loading…
x
Reference in New Issue
Block a user