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