Merge pull request #124335 from zhaofengli/xpra-nvenc

xpra: Add NVENC support
This commit is contained in:
Dmitry Kalinkin 2021-05-28 21:02:22 -04:00 committed by GitHub
commit d26d1125cb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 55 additions and 5 deletions

View file

@ -0,0 +1,22 @@
{ lib, stdenv, fetchgit }:
stdenv.mkDerivation rec {
pname = "nv-codec-headers";
version = "10.0.26.2";
src = fetchgit {
url = "https://git.videolan.org/git/ffmpeg/nv-codec-headers.git";
rev = "n${version}";
sha256 = "0n5jlwjfv5irx1if1g0n52m279bw7ab6bd3jz2v4vwg9cdzbxx85";
};
makeFlags = [ "PREFIX=$(out)" ];
meta = {
description = "FFmpeg version of headers for NVENC";
homepage = "https://ffmpeg.org/";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.MP2E ];
platforms = lib.platforms.all;
};
}

View file

@ -1,12 +1,13 @@
{ lib { lib
, fetchurl , fetchurl
, fetchpatch , fetchpatch
, substituteAll, python3, pkg-config, writeText , substituteAll, python3, pkg-config, runCommand, writeText
, xorg, gtk3, glib, pango, cairo, gdk-pixbuf, atk, pandoc , xorg, gtk3, glib, pango, cairo, gdk-pixbuf, atk, pandoc
, wrapGAppsHook, xorgserver, getopt, xauth, util-linux, which , wrapGAppsHook, xorgserver, getopt, xauth, util-linux, which
, ffmpeg, x264, libvpx, libwebp, x265, librsvg , ffmpeg, x264, libvpx, libwebp, x265, librsvg
, libfakeXinerama , libfakeXinerama
, gst_all_1, pulseaudio, gobject-introspection , gst_all_1, pulseaudio, gobject-introspection
, withNvenc ? false, cudatoolkit, nv-codec-headers-10, nvidia_x11 ? null
, pam }: , pam }:
with lib; with lib;
@ -34,6 +35,13 @@ let
EndSection EndSection
''; '';
nvencHeaders = runCommand "nvenc-headers" {
inherit nvidia_x11;
} ''
mkdir -p $out/include $out/lib/pkgconfig
cp ${nv-codec-headers-10}/include/ffnvcodec/nvEncodeAPI.h $out/include
substituteAll ${./nvenc.pc} $out/lib/pkgconfig/nvenc.pc
'';
in buildPythonApplication rec { in buildPythonApplication rec {
pname = "xpra"; pname = "xpra";
version = "4.2"; version = "4.2";
@ -60,7 +68,8 @@ in buildPythonApplication rec {
substituteInPlace setup.py --replace '/usr/include/security' '${pam}/include/security' substituteInPlace setup.py --replace '/usr/include/security' '${pam}/include/security'
''; '';
nativeBuildInputs = [ pkg-config wrapGAppsHook pandoc ]; nativeBuildInputs = [ pkg-config wrapGAppsHook pandoc ]
++ lib.optional withNvenc cudatoolkit;
buildInputs = with xorg; [ buildInputs = with xorg; [
libX11 xorgproto libXrender libXi libX11 xorgproto libXrender libXi
libXtst libXfixes libXcomposite libXdamage libXtst libXfixes libXcomposite libXdamage
@ -81,13 +90,13 @@ in buildPythonApplication rec {
pam pam
gobject-introspection gobject-introspection
]; ] ++ lib.optional withNvenc nvencHeaders;
propagatedBuildInputs = with python3.pkgs; [ propagatedBuildInputs = with python3.pkgs; [
pillow rencode pycrypto cryptography pycups lz4 dbus-python pillow rencode pycrypto cryptography pycups lz4 dbus-python
netifaces numpy pygobject3 pycairo gst-python pam netifaces numpy pygobject3 pycairo gst-python pam
pyopengl paramiko opencv4 python-uinput pyxdg pyopengl paramiko opencv4 python-uinput pyxdg
ipaddress idna pyinotify ipaddress idna pyinotify
]; ] ++ lib.optionals withNvenc (with python3.pkgs; [pynvml pycuda]);
# error: 'import_cairo' defined but not used # error: 'import_cairo' defined but not used
NIX_CFLAGS_COMPILE = "-Wno-error=unused-function"; NIX_CFLAGS_COMPILE = "-Wno-error=unused-function";
@ -100,7 +109,7 @@ in buildPythonApplication rec {
# Override these, setup.py checks for headers in /usr/* paths # Override these, setup.py checks for headers in /usr/* paths
"--with-pam" "--with-pam"
"--with-vsock" "--with-vsock"
]; ] ++ lib.optional withNvenc "--with-nvenc";
dontWrapGApps = true; dontWrapGApps = true;
preFixup = '' preFixup = ''
@ -111,6 +120,9 @@ in buildPythonApplication rec {
--set XPRA_XKB_CONFIG_ROOT "${xorg.xkeyboardconfig}/share/X11/xkb" --set XPRA_XKB_CONFIG_ROOT "${xorg.xkeyboardconfig}/share/X11/xkb"
--prefix LD_LIBRARY_PATH : ${libfakeXinerama}/lib --prefix LD_LIBRARY_PATH : ${libfakeXinerama}/lib
--prefix PATH : ${lib.makeBinPath [ getopt xorgserver xauth which util-linux pulseaudio ]} --prefix PATH : ${lib.makeBinPath [ getopt xorgserver xauth which util-linux pulseaudio ]}
'' + lib.optionalString withNvenc ''
--prefix LD_LIBRARY_PATH : ${nvidia_x11}/lib
'' + ''
) )
''; '';

View file

@ -0,0 +1,11 @@
prefix=@out@
includedir=${prefix}/include
libdir=@nvidia_x11@/lib
Name: nvenc
Description: NVENC
Version: 10
Requires:
Conflicts:
Libs: -L${libdir} -lnvidia-encode
Cflags: -I${includedir}

View file

@ -17207,6 +17207,7 @@ in
nuspellWithDicts = dicts: callPackage ../development/libraries/nuspell/wrapper.nix { inherit dicts; }; nuspellWithDicts = dicts: callPackage ../development/libraries/nuspell/wrapper.nix { inherit dicts; };
nv-codec-headers = callPackage ../development/libraries/nv-codec-headers { }; nv-codec-headers = callPackage ../development/libraries/nv-codec-headers { };
nv-codec-headers-10 = callPackage ../development/libraries/nv-codec-headers/10_x.nix { };
mkNvidiaContainerPkg = { name, containerRuntimePath, configTemplate, additionalPaths ? [] }: mkNvidiaContainerPkg = { name, containerRuntimePath, configTemplate, additionalPaths ? [] }:
let let
@ -27667,6 +27668,10 @@ in
libxpdf = callPackage ../applications/misc/xpdf/libxpdf.nix { }; libxpdf = callPackage ../applications/misc/xpdf/libxpdf.nix { };
xpra = callPackage ../tools/X11/xpra { }; xpra = callPackage ../tools/X11/xpra { };
xpraWithNvenc = callPackage ../tools/X11/xpra {
withNvenc = true;
nvidia_x11 = linuxPackages.nvidia_x11.override { libsOnly = true; };
};
libfakeXinerama = callPackage ../tools/X11/xpra/libfakeXinerama.nix { }; libfakeXinerama = callPackage ../tools/X11/xpra/libfakeXinerama.nix { };