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

Package Request: SVPManager #64344

Closed
OpenSourceAnarchist opened this issue Jul 5, 2019 · 8 comments · Fixed by #254332
Closed

Package Request: SVPManager #64344

OpenSourceAnarchist opened this issue Jul 5, 2019 · 8 comments · Fixed by #254332

Comments

@OpenSourceAnarchist
Copy link

OpenSourceAnarchist commented Jul 5, 2019

Issue description

All the components to successfully use SVP (SmoothVideoPlayer) appear to be included in Nix/NixOS. Using libsvpflow and vapoursynth (or mpv compiled with vapoursynth support) works, but I would like to use SVPManager itself for having a GUI to configure SVP parameters. It is non-free software but the license is a little ambiguous. Pinging @rnhmjoj because I believe he uses SVP on NixOS.

Using the binary from the Download page results in an error. It will probably work OOTB with patchELF, but I don't have the skill or knowledge to write by own derivation to test.

Note: The developer supports the ideals of GNU/Linux and specifically makes the Linux version available for free with no features restricted. Thus, the only restriction is that it uses a custom license that does not allow alteration of the source code, but does permit redistribution and non-commercial use.

Links:
https://www.svp-team.com/wiki/Main_Page
https://www.svp-team.com/wiki/SVP:Linux
http://www.svp-team.com/files/svp4-latest.php?linux
https://aur.archlinux.org/packages/svp/
https://aur.archlinux.org/cgit/aur.git/tree/?h=svp

@rnhmjoj
Copy link
Contributor

rnhmjoj commented Jul 5, 2019

Pinging @rnhmjoj because I believe he uses SVP on NixOS.

Sorry, I'm not. I use mpv with this script and I'm not interested in packaging or supporting proprietary software in general.

@OpenSourceAnarchist
Copy link
Author

I understand. I may have to learn Nix packaging to get this included... I doubt anyone else uses this anyway!

@stale
Copy link

stale bot commented Jun 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 2, 2020
@Maxwell-lt
Copy link
Contributor

I'm interested in using SVP, and I've made some progress packaging it. So far I have a derivation that unpacks and patchelfs all the binaries, but I'm still unable to get SVPManager to actually launch.

When running SVPManager, it crashes with an error that appears to be from Zenity, This option is not available. Please see --help for all possible usages. I don't really know how to track down the cause of this issue, but the command itself found using strace seems to be okay.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 20, 2020
@Sinity
Copy link

Sinity commented Dec 16, 2020

@Maxwell-lt

Same issue. I also tried running it with steam-run. It seems to fail even worse.

Some extensions missed libPythonQt.so libQtWebApp.so and libQtZeroConf.so, which were placed next to them,
so I did the following before testing, but it still fails the same. I don't know whether /run/opengl-driver/lib is necessary, added just in case.
Hook to do it automatically seems to conflict with other hooks (or I'm just using it wrong)

I doubt it crashes because of 'extensions' anyway.

> export LD_LIBRARY_PATH=`pwd`:`pwd`/extensions:`pwd`/plugins:/run/opengl-driver/lib

> env | grep LD_LIBRARY_PATH    
                                    
LD_LIBRARY_PATH=/nix/store/n7qkam4x0qxyzfb6fvrp9zp5s91r6gnj-svp-4.3.191/opt:/nix/store/n7qkam4x0qxyzfb6fvrp9zp5s91r6gnj-svp-4.3.191/opt/extensions:/nix/store/n7qkam4x0qxyzfb6fvrp9zp5s91r6gnj-svp-4.3.191/opt/plugins:/run/opengl-driver/lib

ldd .SVPManager-wrapped:

        linux-vdso.so.1 (0x00007fff0d175000)
	libX11.so.6 => /nix/store/adzfjjh8w25vdr0xdx9x16ah4f5rqrw5-libX11-1.7.0/lib/libX11.so.6 (0x00007febda8cd000)
	libdl.so.2 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/libdl.so.2 (0x00007febda8c8000)
	libQt5Widgets.so.5 => /nix/store/8kzv5i43ycnipc9p1saqpqc7729dg35d-qtbase-5.15.0/lib/libQt5Widgets.so.5 (0x00007febda221000)
	libQt5Gui.so.5 => /nix/store/8kzv5i43ycnipc9p1saqpqc7729dg35d-qtbase-5.15.0/lib/libQt5Gui.so.5 (0x00007febd9bc7000)
	libQt5Qml.so.5 => /nix/store/w45x15b37p8v55iyibpn29zvi629xfny-qtdeclarative-5.15.0/lib/libQt5Qml.so.5 (0x00007febd9710000)
	libQt5Network.so.5 => /nix/store/8kzv5i43ycnipc9p1saqpqc7729dg35d-qtbase-5.15.0/lib/libQt5Network.so.5 (0x00007febd9550000)
	libQt5Concurrent.so.5 => /nix/store/8kzv5i43ycnipc9p1saqpqc7729dg35d-qtbase-5.15.0/lib/libQt5Concurrent.so.5 (0x00007febd9547000)
	libQt5Core.so.5 => /nix/store/8kzv5i43ycnipc9p1saqpqc7729dg35d-qtbase-5.15.0/lib/libQt5Core.so.5 (0x00007febd8f98000)
	libpthread.so.0 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/libpthread.so.0 (0x00007febd8f77000)
	libstdc++.so.6 => /nix/store/7in2alrzhkpcax5fk4823ismvsmdk1aj-gcc-9.3.0-lib/lib/libstdc++.so.6 (0x00007febd8d96000)
	libm.so.6 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/libm.so.6 (0x00007febd8c51000)
	libgcc_s.so.1 => /nix/store/7in2alrzhkpcax5fk4823ismvsmdk1aj-gcc-9.3.0-lib/lib/libgcc_s.so.1 (0x00007febd8c37000)
	libc.so.6 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/libc.so.6 (0x00007febd8a76000)
	libxcb.so.1 => /nix/store/44m4434m802xvivk8j1qj6ga53q56wrw-libxcb-1.14/lib/libxcb.so.1 (0x00007febd8a4b000)
	/nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/ld-linux-x86-64.so.2 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib64/ld-linux-x86-64.so.2 (0x00007febdc92b000)
	libGL.so.1 => /nix/store/zk8sbcd70gmk1cp7fsl2155g7sw1nzb3-libGL-1.3.2/lib/libGL.so.1 (0x00007febd89bd000)
	libpng16.so.16 => /nix/store/n4ds741zsjji4xj7ms4qlaf28lxk392y-libpng-apng-1.6.37/lib/libpng16.so.16 (0x00007febd8982000)
	libz.so.1 => /nix/store/ys6akcfqbzbmvfz97l8mj2fmyilrh3hp-zlib-1.2.11/lib/libz.so.1 (0x00007febd8965000)
	libharfbuzz.so.0 => /nix/store/fiix5d75x91x70bs7pxspi74c1l5ms1m-harfbuzz-2.7.2/lib/libharfbuzz.so.0 (0x00007febd8864000)
	librt.so.1 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/librt.so.1 (0x00007febd885a000)
	libgssapi_krb5.so.2 => /nix/store/0jr79prrz92nx3qdf4b8ap526spvc656-libkrb5-1.18/lib/libgssapi_krb5.so.2 (0x00007febd8805000)
	libssl.so.1.1 => /nix/store/31dfd62q1456yj5n0r6mfj4qpknhfvpd-openssl-1.1.1h/lib/libssl.so.1.1 (0x00007febd876f000)
	libcrypto.so.1.1 => /nix/store/31dfd62q1456yj5n0r6mfj4qpknhfvpd-openssl-1.1.1h/lib/libcrypto.so.1.1 (0x00007febd8481000)
	libicui18n.so.67 => /nix/store/db8ghplv35b5ywd7qwrh3ikm2frxxa8a-icu4c-67.1/lib/libicui18n.so.67 (0x00007febd8171000)
	libicuuc.so.67 => /nix/store/db8ghplv35b5ywd7qwrh3ikm2frxxa8a-icu4c-67.1/lib/libicuuc.so.67 (0x00007febd7f84000)
	libicudata.so.67 => /nix/store/db8ghplv35b5ywd7qwrh3ikm2frxxa8a-icu4c-67.1/lib/libicudata.so.67 (0x00007febd646d000)
	libpcre2-16.so.0 => /nix/store/nbbcqdwssvnv6315lg1j87ajq2r02nif-pcre2-10.35/lib/libpcre2-16.so.0 (0x00007febd63e8000)
	libgthread-2.0.so.0 => /nix/store/iwj5pmz0nnal8k5g3jxmlm4h8rkqf9g0-glib-2.66.3/lib/libgthread-2.0.so.0 (0x00007febd63e3000)
	libglib-2.0.so.0 => /nix/store/iwj5pmz0nnal8k5g3jxmlm4h8rkqf9g0-glib-2.66.3/lib/libglib-2.0.so.0 (0x00007febd62b3000)
	libXau.so.6 => /nix/store/bavjgcrxbjvv2p6wfvbvl1mlc1jqaxnm-libXau-1.0.9/lib/libXau.so.6 (0x00007febd62ac000)
	libXdmcp.so.6 => /nix/store/8015c01rsxwas0clrnrlmcjrc6nys7mz-libXdmcp-1.1.3/lib/libXdmcp.so.6 (0x00007febd62a4000)
	libGLX.so.0 => /nix/store/yac0mc9q0vfsax33gsnmj1cpvp8pcc4v-libglvnd-1.3.2/lib/libGLX.so.0 (0x00007febd6270000)
	libXext.so.6 => /nix/store/brasbayks9qvsy2hvc4rjml5fmif9kqd-libXext-1.3.4/lib/libXext.so.6 (0x00007febd625b000)
	libGLdispatch.so.0 => /nix/store/yac0mc9q0vfsax33gsnmj1cpvp8pcc4v-libglvnd-1.3.2/lib/libGLdispatch.so.0 (0x00007febd61a2000)
	libfreetype.so.6 => /nix/store/0ljzwkymlijx965ybcc59x343362s3hz-freetype-2.10.4/lib/libfreetype.so.6 (0x00007febd60dd000)
	libgraphite2.so.3 => /nix/store/f9vvdawkn1fxiifdhjniic18j904l8w1-graphite2-1.3.14/lib/libgraphite2.so.3 (0x00007febd60b3000)
	libkrb5.so.3 => /nix/store/0jr79prrz92nx3qdf4b8ap526spvc656-libkrb5-1.18/lib/libkrb5.so.3 (0x00007febd5fd9000)
	libk5crypto.so.3 => /nix/store/0jr79prrz92nx3qdf4b8ap526spvc656-libkrb5-1.18/lib/libk5crypto.so.3 (0x00007febd5fa9000)
	libcom_err.so.3 => /nix/store/0jr79prrz92nx3qdf4b8ap526spvc656-libkrb5-1.18/lib/libcom_err.so.3 (0x00007febd5fa1000)
	libkrb5support.so.0 => /nix/store/0jr79prrz92nx3qdf4b8ap526spvc656-libkrb5-1.18/lib/libkrb5support.so.0 (0x00007febd5f92000)
	libkeyutils.so.1 => /nix/store/2hk7nylygj4bm89lk7xlc6j8479rgp1s-keyutils-1.6.3-lib/lib/libkeyutils.so.1 (0x00007febd5f8b000)
	libresolv.so.2 => /nix/store/9l06v7fc38c1x3r2iydl15ksgz0ysb82-glibc-2.32/lib/libresolv.so.2 (0x00007febd5f72000)
	libpcre.so.1 => /nix/store/xkb8r7gfc47r48wa1i2lihphcxgk7nsj-pcre-8.44/lib/libpcre.so.1 (0x00007febd5f00000)
	libbz2.so.1 => /nix/store/lmw5nvbhnkvmg42473aw68kzslg38q4n-bzip2-1.0.6.0.1/lib/libbz2.so.1 (0x00007febd5eeb000)

steam-run SVPManager:
/run/current-system/sw/bin/zenity: symbol lookup error: /nix/store/im9dlyzrrdzvi6r4syif985kj8dpvvf5-tracker-3.0.1/lib/libtracker-sparql-3.0.so.0: undefined symbol: sqlite3_value_free S«ý4¦ßlàV¶sHø[äyÃHç×Kûs"b? jÑ>SĤfßT¯P´cVÓrî½7i5·Mþ®ϖAaC

svpmanager_strace

I'll include my derivations. In configure.nix I have

packageOverrides = pkgs: rec { polybar = pkgs.polybar.override { i3Support = true; }; mpv = pkgs.wrapMpv (pkgs.mpv-unwrapped.override { vapoursynthSupport = true; }) { youtubeSupport = true; }; };

and, in system packages: (import ./svpflow.nix) (import ./svpmanager.nix)

svpflow.nix:

with import <nixpkgs> {};
stdenv.mkDerivation rec {
  name = "svpflow-${version}";
  version = "4.3.0.168";

  src = fetchurl {
    url = "https://www.svp-team.com/files/gpl/svpflow-${version}.zip";
    sha256 = "13px50ijrrv1v2cvzbsrfasdqsshx782fl3fhk67iwi86mpa0hpx";
  };

  nativeBuildInputs = [
    unzip
    addOpenGLRunpath
  ];

  sourceRoot = ".";

  buildInputs = [
  ];

  unpackPhase = ''
    unzip -j $src lib-linux?libsvpflow{1,2}_vs64.so
  '';

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    mkdir -p $out/lib
    cp libsvpflow{1,2}_vs64.so $out/lib/
  '';

   preFixup = let
     libPath = lib.makeLibraryPath [
       stdenv.cc.cc.lib
     ];
   in ''
     patchelf --set-rpath "${libPath}" $out/lib/libsvpflow1_vs64.so
     patchelf --set-rpath "${libPath}" $out/lib/libsvpflow2_vs64.so
   '';

   postFixup = ''
     addOpenGLRunpath $out/lib/libsvpflow1_vs64.so
     addOpenGLRunpath $out/lib/libsvpflow2_vs64.so
   '';

  meta = with stdenv.lib; {
    homepage = https://svp-team.com/;
    description = "SmoothVideo Project - svpflow libraries";
    platforms = platforms.linux;
    maintainers = with maintainers; [ sinity ];
  };
}

svpmanager.nix (based on AUR package):

with import <nixpkgs> {};
stdenv.mkDerivation rec {
  name = "svp-${version}";
  version = "4.3.191";

  src = fetchurl {
    url = "https://gist.githubusercontent.com/phiresky/1e2cbd30bed4e5978771af232d11afd1/raw/svp4-linux.${version}.tar.bz2";
    sha256 = "b29970277fe35e8954f3b126b9016d23143be7b23fcfe17d350c59a25f1fa468";
  };

  nativeBuildInputs = [
    p7zip
    qt5.wrapQtAppsHook
    #addOpenGLRunpath #autoPatchelfHook #makeWrapper
  ];

  buildInputs = [
    stdenv.cc.cc.lib
    qt5.qtbase qt5.qtdeclarative qt5.qtscript qt5.qtsvg
    xlibs.libX11

    libmediainfo
    libusb1

    python3Full
    avahi

    vapoursynth
    ocl-icd
    (import ./svpflow.nix)

    gnome3.tracker # steam-run causes zenity to complain about undefined symbol
  ];

  unpackPhase = ''
    tar -xf $src
    mkdir installer
    ls -la
    LANG=C grep --only-matching --byte-offset --binary --text  $'7z\xBC\xAF\x27\x1C' "svp4-linux-64.run" | cut -f1 -d: | while read ofs; do dd if="svp4-linux-64.run" bs=1M iflag=skip_bytes status=none skip=$ofs of="installer/bin-$ofs.7z"; done
    echo "7z extracted"
    ls -la installer/
    mkdir extracted
    for f in installer/*.7z; do
      7z -bd -bb0 -y x -o"extracted/" "$f" || true
    done

    rm extracted/extensions/libsvpcode.so
    rm extracted/plugins/libsvpflow1_vs64.so
    rm extracted/plugins/libsvpflow2_vs64.so
    #rm -rf extracted/extensions/*
  '';

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    mkdir -p $out/{opt,lib,bin}
    cp -R extracted/* $out/opt

    ln -s $out/opt/extensions/libPythonQt.so $out/opt/extensions/libPythonQt.so.1
    ln -s $out/opt/extensions/libQtWebApp.so $out/opt/extensions/libQtWebApp.so.1
    ln -s $out/opt/extensions/libQtZeroConf.so $out/opt/extensions/libQtZeroConf.so.1

    ln -s $out/opt/extensions/libPythonQt.so $out/lib/libPythonQt.so
    ln -s $out/opt/extensions/libPythonQt.so $out/lib/libPythonQt.so.1
    ln -s $out/opt/extensions/libQtWebApp.so $out/lib/libQtWebApp.so
    ln -s $out/opt/extensions/libQtWebApp.so $out/lib/libQtWebApp.so.1
    ln -s $out/opt/extensions/libQtZeroConf.so $out/lib/libQtZeroConf.so
    ln -s $out/opt/extensions/libQtZeroConf.so $out/lib/libQtZeroConf.so.1

    ln -s $out/opt/SVPManager $out/bin/SVPManager

    chmod -R 755 $out
  '';

  preFixup = let
    libPath = lib.makeLibraryPath buildInputs;
  in ''
    patchelf --set-rpath "${libPath}" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/opt/SVPManager
    patchelf --set-rpath "${libPath}" --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/opt/utils/clinfo

    #patchelf --set-rpath "${libPath}" $out/opt/extensions/libPythonQt.so.1
    patchelf --set-rpath "${libPath}" $out/opt/extensions/libPythonQt.so
    #patchelf --set-rpath "${libPath}" $out/opt/extensions/libQtWebApp.so.1
    patchelf --set-rpath "${libPath}" $out/opt/extensions/libQtWebApp.so
    #patchelf --set-rpath "${libPath}" $out/opt/extensions/libQtZeroConf.so.1
    patchelf --set-rpath "${libPath}" $out/opt/extensions/libQtZeroConf.so
    patchelf --set-rpath "${libPath}" $out/opt/extensions/libsvpcast.so
    patchelf --set-rpath "${libPath}" $out/opt/extensions/libsvplight.so
    patchelf --set-rpath "${libPath}" $out/opt/extensions/libsvptube.so

    patchelf --set-rpath "${libPath}" $out/opt/plugins/libsvpcontrol_plugin.so.30
    patchelf --set-rpath "${libPath}" $out/opt/plugins/libvapoursynth_plugin.so.30
  '';

  postFixup = ''
    #addOpenGLRunpath $out/opt/SVPManager
  '';

  meta = with stdenv.lib; {
    homepage = https://svp-team.com/;
    description = "SmoothVideo Project";
    platforms = platforms.linux;
    maintainers = with maintainers; [ sinity ];
  };
}

Svpflow is separate because it seems to actually work. Through - for some reason - not with nvidia optical flow. I'd prefer to be able to run the manager as well, through. And to use the libs correctly, one would need to generate .vpy scripts through javascript generators.

Here's how I'm using it now: svp.py:

import vapoursynth as vs
core = vs.get_core(threads=25)

core.std.LoadPlugin("/run/current-system/sw/lib/libsvpflow1_vs64.so")
core.std.LoadPlugin("/run/current-system/sw/lib/libsvpflow2_vs64.so")

clip = video_in

super_params     = "{scale:{up:0},gpu:1,rc:true}"
analyse_params   = "{block:{w:32},main:{search:{coarse:{type:2,distance:-6,bad:{sad:2000,range:24}},type:2}},refine:[{thsad:250}]}"
smoothfps_params = "{gpuid:11,gpu_qn:2,rate:{num:100,den:1,abs:true},algo:2,mask:{area:50},scene:{},light:{aspect:2.389,lights:29,border:107,length:187,cell:5}}"

src_fps     = container_fps if container_fps>0.1 else 29.97
demo_mode   = 0
stereo_type = 0
nvof = 0

def interpolate(clip):
# input_um - original frame in 4:2:0
# input_m  - cropped and resized (if needed) frame
# input_m8 - input_m converted to 8-bit
    input_um = clip.resize.Point(format=vs.YUV420P8,dither_type="random")
    input_m = input_um
    input_m8 = input_m

    if nvof:
        smooth  = core.svp2.SmoothFps_NVOF(input_m,smoothfps_params,nvof_src=input_m8,src=input_um,fps=src_fps)
    else:
        super   = core.svp1.Super(input_m8,super_params)
        vectors = core.svp1.Analyse(super["clip"],super["data"],input_m8,analyse_params)
        smooth  = core.svp2.SmoothFps(input_m,super["clip"],super["data"],vectors["clip"],vectors["data"],smoothfps_params,src=input_um,fps=src_fps)

    if demo_mode==1:
        return demo(input_m,smooth)
    else:
        return smooth

if stereo_type == 1:
    lf = interpolate(core.std.CropRel(clip,0,(int)(clip.width/2),0,0))
    rf = interpolate(core.std.CropRel(clip,(int)(clip.width/2),0,0,0))
    smooth = core.std.StackHorizontal([lf, rf])
elif stereo_type == 2:
    lf = interpolate(core.std.CropRel(clip,0,0,0,(int)(clip.height/2)))
    rf = interpolate(core.std.CropRel(clip,0,0,(int)(clip.height/2),0))
    smooth = core.std.StackVertical([lf, rf])
else:
    smooth = interpolate(clip)

smooth.set_output()

script could be placed in mpv's config folder (like ~/.config/mpv), and toggled on/off with 'v' key by adding this line to input.conf: v vf toggle vapoursynth=~~/svp.py:2:24

@stale
Copy link

stale bot commented Jun 16, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 16, 2021
@VolodiaPG
Copy link

VolodiaPG commented Sep 10, 2022

After spending some time trying to make sense of the progress posted here, I stumbled upon Lan Tian's blog describing how to package SVP. He encapsulates the package to make it thinks it is executing on a FHS-compliant (linux-standard) filesystem. The reason, citing Lan Tian:

Other closed source ones, to avoid being cracked, will check their own integrities, and refuse to start if their binary files are ever changed. SVP video interpolation software, for example, is one of them.

His contribution is also available—and looks up-to-date at the moment of writing—on the NUR inititive published here and works perfectly once you setup the NUR channel.

P.S.
Additionally, I am also putting a wrapper of mine to make the gnome shortcut able to execute on a wayland session.

# configuration.nix

# MPV w/ vapoursynth support, as required by SVP
nixpkgs.config.packageOverrides = pkgs: rec {
    # mistune = pkgs.mistune_2_0;
    mpv = (pkgs.mpv-unwrapped.override {
      vapoursynthSupport = true;
      vapoursynth = pkgs.vapoursynth;
    }).overrideAttrs (old: rec {
      wafConfigureFlags = old.wafConfigureFlags ++ [ "--enable-vapoursynth" ];
    });
  };

environment.systemPackages = with pkgs; [
    # MPV
    (mpv-with-scripts.override { scripts = [ mpvScripts.mpris ]; })

    # SVP-related requirements
    libsForQt5.qt5.qtwayland # Allow SVP to run on wayland
    (pkgs.callPackage ../pkgs/svp { })
    # ...
]
# In svp/default.nix
{
  pkgs ? import <nixpkgs> {},
  lib ? pkgs.lib,
}:
let
  originalPackage = pkgs.nur.repos.xddxdd.svp;

  # We use `overrideAttrs` instead of defining a new `mkDerivation` to keep
  # the original package's `output`, `passthru`, and so on.
  svpOverridenWayland = originalPackage.overrideAttrs (old: {
    name = "svp-overriden-with-wayland";

    # Using `buildCommand` replaces the original packages build phases.
    buildCommand = ''
      set -euo pipefail

      ${
        # Copy original files, for each split-output (`out`, `dev` etc.).
        # E.g. `${package.dev}` to `$dev`, and so on. If none, just "out".
        # Symlink all files from the original package to here (`cp -rs`),
        # to save disk space.
        # We could alternatiively also copy (`cp -a --no-preserve=mode`).
        lib.concatStringsSep "\n"
          (map
            (outputName:
              ''
                echo "Copying output ${outputName}"
                set -x
                cp -rs --no-preserve=mode "${originalPackage.${outputName}}" "''$${outputName}"
                set +x
              ''
            )
            (old.outputs or ["out"])
          )
      }

      # Change `Exec` in the desktop entry to insert an env variable forcing wayland for QT5
      # Make the file to be not a symlink by full copying using `install` first.
      # This also makes it writable (files in the nix store have `chmod -w`).
      install -v "${originalPackage}"/share/applications/svp-manager4.desktop "$out"/share/applications/svp-manager4.desktop
      sed -i -e 's/Exec=/Exec=env QT_QPA_PLATFORM=wayland /g' "$out"/share/applications/svp-manager4.desktop
    '';
  });
in
  svpOverridenWayland

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Sep 10, 2022
@LunNova
Copy link
Member

LunNova commented Sep 10, 2022

Example with SVP working with home-manager: https://github.com/LunNova/nixos-configs/blob/150784baab2c36d8b02de22b1cecbcc33fdf8fb2/users/lun/media/default.nix

This doesn't use SVP manager and is using the outdated last release of the .so that was packaged separately, but it works well enough for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants