Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP emby: 3.5.2.0 -> 3.5.3.0 and migration from mono to dotnet #47659

Merged
merged 4 commits into from
Oct 4, 2018
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 14 additions & 15 deletions pkgs/servers/emby/default.nix
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{ stdenv, fetchurl, unzip, sqlite, makeWrapper, mono54, ffmpeg }:
{ stdenv, fetchurl, unzip, sqlite, makeWrapper, dotnet-sdk, ffmpeg }:

stdenv.mkDerivation rec {
name = "emby-${version}";
version = "3.5.2.0";
version = "3.5.3.0";

# We are fetching a binary here, however, a source build is possible.
# See -> https://aur.archlinux.org/cgit/aur.git/tree/PKGBUILD?h=emby-server-git#n43
Expand All @@ -11,8 +11,8 @@ stdenv.mkDerivation rec {
# This may also need msbuild (instead of xbuild) which isn't in nixpkgs
# See -> https://github.com/NixOS/nixpkgs/issues/29817
src = fetchurl {
url = "https://github.com/MediaBrowser/Emby.Releases/releases/download/${version}/embyserver-mono_${version}.zip";
sha256 = "12f9skvnr9qxnrvr3q014yggfwvkpjk0ynbgf0fwk56h4kal7fx8";
url = "https://github.com/MediaBrowser/Emby.Releases/releases/download/${version}/embyserver-netcore_${version}.zip";
sha256 = "0311af3q813cx0ykbdk9vkmnyqi2l8rx66jnvdkw927q6invnnpj";
};

buildInputs = [
Expand All @@ -21,26 +21,25 @@ stdenv.mkDerivation rec {
];

propagatedBuildInputs = [
mono54
dotnet-sdk
sqlite
];

preferLocalBuild = true;

# Need to set sourceRoot as unpacker will complain about multiple directory output
sourceRoot = ".";

buildPhase = ''
substituteInPlace SQLitePCLRaw.provider.sqlite3.dll.config --replace libsqlite3.so ${sqlite.out}/lib/libsqlite3.so
substituteInPlace MediaBrowser.Server.Mono.exe.config --replace ProgramData-Server "/var/lib/emby/ProgramData-Server"
rm -rf {electron,runtimes}
'';

installPhase = ''
mkdir -p "$out/bin"
cp -r * "$out/bin"

makeWrapper "${mono54}/bin/mono" $out/bin/MediaBrowser.Server.Mono \
--add-flags "$out/bin/MediaBrowser.Server.Mono.exe -ffmpeg ${ffmpeg}/bin/ffmpeg -ffprobe ${ffmpeg}/bin/ffprobe"
install -dm 755 "$out/usr/lib/emby-server"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nyanloutre This path shouldn't have usr/ in the nix store.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is /lib the correct folder ? I putted it here because it mostly consisted of dll files, but maybe /opt would be better ?

cp -r * "$out/usr/lib/emby-server"
Copy link
Contributor

@baracoder baracoder Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this will copy env-vars file to the destination directory, which can contain references to other packages not needed at runtime, similar to #47269

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest would be appropriate?

Copy link
Contributor

@baracoder baracoder Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the linked issue, I have changed the unpacking phase to create the expected source directory

    unpackPhase = ''
      mkdir src
      cd src
      tar xvzf $src
    '';

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't figure out what shouldn't be copied. By inspecting the result simlink it seems that only needed files are here.

Copy link
Contributor

@baracoder baracoder Oct 2, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have tested the build and there are no unwanted files in the result directory.
It seams I have misunderstood the origin of the problem in the other issue:
I assumed that the env-vars file is created as part of the setup for every build, but it is not. Also it seams to be not required, that an archive contains a directory for the files first. I will have to look at why it is again.
So I am sorry for adding this confusion.
Edit: 🤦‍♂️ Found my stupid mistake: The new zip file is organized in the expected manner. There is only one subdirectory named system, so everything works out.


makeWrapper "${dotnet-sdk}/bin/dotnet" $out/bin/emby \
--prefix LD_LIBRARY_PATH : "${stdenv.lib.makeLibraryPath [
sqlite
]}" \
--add-flags "$out/usr/lib/emby-server/EmbyServer.dll -programdata /var/lib/emby/ProgramData-Server -ffmpeg ${ffmpeg}/bin/ffmpeg -ffprobe ${ffmpeg}/bin/ffprobe"
'';

meta = with stdenv.lib; {
Expand Down