Loading pkgs/applications/video/gpu-screen-recorder/default.nix +33 −21 Original line number Diff line number Diff line { stdenv, lib, fetchgit, makeWrapper, pkg-config, cudatoolkit, glew, libX11 , libXcomposite, glfw, libpulseaudio, ffmpeg }: stdenv.mkDerivation rec { { stdenv , lib , fetchurl , makeWrapper , pkg-config , libXcomposite , libpulseaudio , ffmpeg , wayland , libdrm , libva , libglvnd , libXrandr }: stdenv.mkDerivation { pname = "gpu-screen-recorder"; version = "1.0.0"; version = "unstable-2023-11-18"; src = fetchgit { url = "https://repo.dec05eba.com/gpu-screen-recorder"; rev = "36fd4516db06bcb192e49055319d1778bbed0322"; sha256 = "sha256-hYEHM4FOYcPmQ5Yxh520PKy8HiD+G0xv9hrn8SmA07w="; # printf "r%s.%s\n" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" src = fetchurl { url = "https://dec05eba.com/snapshot/gpu-screen-recorder.git.r418.5a8900e.tar.gz"; hash = "sha256-Dal6KxQOTqoNH6e8lYk5XEXGFG/vzbguNFZ9yk9nKe0="; }; sourceRoot = "."; nativeBuildInputs = [ pkg-config Loading @@ -17,27 +30,26 @@ stdenv.mkDerivation rec { ]; buildInputs = [ glew libX11 libXcomposite glfw libpulseaudio ffmpeg wayland libdrm libva libXrandr ]; postPatch = '' substituteInPlace ./build.sh \ --replace '/opt/cuda/targets/x86_64-linux/include' '${cudatoolkit}/targets/x86_64-linux/include' \ --replace '/usr/lib64/libcuda.so' '${cudatoolkit}/targets/x86_64-linux/lib/stubs/libcuda.so' ''; buildPhase = '' ./build.sh ''; installPhase = '' install -Dt $out/bin/ gpu-screen-recorder wrapProgram $out/bin/gpu-screen-recorder --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib postInstall = '' install -Dt $out/bin gpu-screen-recorder gsr-kms-server mkdir $out/bin/.wrapped mv $out/bin/gpu-screen-recorder $out/bin/.wrapped/ makeWrapper "$out/bin/.wrapped/gpu-screen-recorder" "$out/bin/gpu-screen-recorder" \ --prefix LD_LIBRARY_PATH : ${libglvnd}/lib \ --prefix PATH : $out/bin ''; meta = with lib; { Loading pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patchdeleted 100644 → 0 +0 −38 Original line number Diff line number Diff line diff --git a/build.sh b/build.sh index 05603db..8c38b31 100755 --- a/build.sh +++ b/build.sh @@ -2,5 +2,5 @@ dependencies="gtk+-3.0 x11 xrandr libpulse" includes="$(pkg-config --cflags $dependencies)" -libs="$(pkg-config --libs $dependencies)" +libs="$(pkg-config --libs $dependencies) -ldl" g++ -o gpu-screen-recorder-gtk -O2 src/main.cpp -s $includes $libs diff --git a/src/main.cpp b/src/main.cpp index ae2078f..9dcdce1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ #include <pwd.h> #include <libgen.h> #include <functional> +#include <dlfcn.h> typedef struct { Display *display; @@ -830,7 +831,13 @@ static void audio_input_change_callback(GtkComboBox *widget, gpointer userdata) } static bool is_nv_fbc_installed() { - return access("/usr/lib/libnvidia-fbc.so.1", F_OK) == 0 || access("/usr/local/lib/libnvidia-fbc.so.1", F_OK) == 0; + auto handle = dlopen("libnvidia-fbc.so.1", RTLD_LAZY); + if (handle) { + dlclose(handle); + return true; + } else { + return false; + } } static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *app) { pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix +24 −14 Original line number Diff line number Diff line { stdenv, lib, fetchgit, pkg-config, makeWrapper, gtk3, libX11, libXrandr , libpulseaudio, gpu-screen-recorder }: stdenv.mkDerivation rec { { stdenv , lib , fetchurl , pkg-config , makeWrapper , gtk3 , libpulseaudio , libdrm , gpu-screen-recorder , libglvnd , wrapGAppsHook }: stdenv.mkDerivation { pname = "gpu-screen-recorder-gtk"; version = "0.1.0"; version = "3.2.5"; src = fetchgit { url = "https://repo.dec05eba.com/gpu-screen-recorder-gtk"; rev = "4c317abd0531f8e155fbbbcd32850bbeebbf2ead"; sha256 = "sha256-5W6qmUMP31ndRDxMHuQ/XnZysPQgaie0vVlMTzfODU4="; src = fetchurl { url = "https://dec05eba.com/snapshot/gpu-screen-recorder-gtk.git.r175.cfd18af.tar.gz"; hash = "sha256-HhZe22Hm9yGoy5WoyuP2+Wj8E3nMs4uf96mzmP6CMqU="; }; patches = [ ./fix-nvfbc-check.patch ]; sourceRoot = "."; nativeBuildInputs = [ pkg-config makeWrapper wrapGAppsHook ]; buildInputs = [ gtk3 libX11 libXrandr libpulseaudio libdrm ]; buildPhase = '' Loading @@ -33,7 +41,9 @@ stdenv.mkDerivation rec { install -Dt $out/bin/ gpu-screen-recorder-gtk install -Dt $out/share/applications/ gpu-screen-recorder-gtk.desktop wrapProgram $out/bin/gpu-screen-recorder-gtk --prefix PATH : ${lib.makeBinPath [ gpu-screen-recorder ]} gappsWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ gpu-screen-recorder ]}) # we also append /run/opengl-driver/lib as it otherwise fails to find libcuda. gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libglvnd ]}:/run/opengl-driver/lib) ''; meta = with lib; { Loading pkgs/top-level/all-packages.nix +1 −4 Original line number Diff line number Diff line Loading @@ -32297,10 +32297,7 @@ with pkgs; gpsprune = callPackage ../applications/misc/gpsprune { }; gpu-screen-recorder = callPackage ../applications/video/gpu-screen-recorder { # rm me as soon as this package gains the support for cuda 11 inherit (cudaPackages_10) cudatoolkit; }; gpu-screen-recorder = callPackage ../applications/video/gpu-screen-recorder { }; gpu-screen-recorder-gtk = callPackage ../applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix { }; Loading
pkgs/applications/video/gpu-screen-recorder/default.nix +33 −21 Original line number Diff line number Diff line { stdenv, lib, fetchgit, makeWrapper, pkg-config, cudatoolkit, glew, libX11 , libXcomposite, glfw, libpulseaudio, ffmpeg }: stdenv.mkDerivation rec { { stdenv , lib , fetchurl , makeWrapper , pkg-config , libXcomposite , libpulseaudio , ffmpeg , wayland , libdrm , libva , libglvnd , libXrandr }: stdenv.mkDerivation { pname = "gpu-screen-recorder"; version = "1.0.0"; version = "unstable-2023-11-18"; src = fetchgit { url = "https://repo.dec05eba.com/gpu-screen-recorder"; rev = "36fd4516db06bcb192e49055319d1778bbed0322"; sha256 = "sha256-hYEHM4FOYcPmQ5Yxh520PKy8HiD+G0xv9hrn8SmA07w="; # printf "r%s.%s\n" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)" src = fetchurl { url = "https://dec05eba.com/snapshot/gpu-screen-recorder.git.r418.5a8900e.tar.gz"; hash = "sha256-Dal6KxQOTqoNH6e8lYk5XEXGFG/vzbguNFZ9yk9nKe0="; }; sourceRoot = "."; nativeBuildInputs = [ pkg-config Loading @@ -17,27 +30,26 @@ stdenv.mkDerivation rec { ]; buildInputs = [ glew libX11 libXcomposite glfw libpulseaudio ffmpeg wayland libdrm libva libXrandr ]; postPatch = '' substituteInPlace ./build.sh \ --replace '/opt/cuda/targets/x86_64-linux/include' '${cudatoolkit}/targets/x86_64-linux/include' \ --replace '/usr/lib64/libcuda.so' '${cudatoolkit}/targets/x86_64-linux/lib/stubs/libcuda.so' ''; buildPhase = '' ./build.sh ''; installPhase = '' install -Dt $out/bin/ gpu-screen-recorder wrapProgram $out/bin/gpu-screen-recorder --prefix LD_LIBRARY_PATH : /run/opengl-driver/lib postInstall = '' install -Dt $out/bin gpu-screen-recorder gsr-kms-server mkdir $out/bin/.wrapped mv $out/bin/gpu-screen-recorder $out/bin/.wrapped/ makeWrapper "$out/bin/.wrapped/gpu-screen-recorder" "$out/bin/gpu-screen-recorder" \ --prefix LD_LIBRARY_PATH : ${libglvnd}/lib \ --prefix PATH : $out/bin ''; meta = with lib; { Loading
pkgs/applications/video/gpu-screen-recorder/fix-nvfbc-check.patchdeleted 100644 → 0 +0 −38 Original line number Diff line number Diff line diff --git a/build.sh b/build.sh index 05603db..8c38b31 100755 --- a/build.sh +++ b/build.sh @@ -2,5 +2,5 @@ dependencies="gtk+-3.0 x11 xrandr libpulse" includes="$(pkg-config --cflags $dependencies)" -libs="$(pkg-config --libs $dependencies)" +libs="$(pkg-config --libs $dependencies) -ldl" g++ -o gpu-screen-recorder-gtk -O2 src/main.cpp -s $includes $libs diff --git a/src/main.cpp b/src/main.cpp index ae2078f..9dcdce1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -15,6 +15,7 @@ #include <pwd.h> #include <libgen.h> #include <functional> +#include <dlfcn.h> typedef struct { Display *display; @@ -830,7 +831,13 @@ static void audio_input_change_callback(GtkComboBox *widget, gpointer userdata) } static bool is_nv_fbc_installed() { - return access("/usr/lib/libnvidia-fbc.so.1", F_OK) == 0 || access("/usr/local/lib/libnvidia-fbc.so.1", F_OK) == 0; + auto handle = dlopen("libnvidia-fbc.so.1", RTLD_LAZY); + if (handle) { + dlclose(handle); + return true; + } else { + return false; + } } static GtkWidget* create_common_settings_page(GtkStack *stack, GtkApplication *app) {
pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix +24 −14 Original line number Diff line number Diff line { stdenv, lib, fetchgit, pkg-config, makeWrapper, gtk3, libX11, libXrandr , libpulseaudio, gpu-screen-recorder }: stdenv.mkDerivation rec { { stdenv , lib , fetchurl , pkg-config , makeWrapper , gtk3 , libpulseaudio , libdrm , gpu-screen-recorder , libglvnd , wrapGAppsHook }: stdenv.mkDerivation { pname = "gpu-screen-recorder-gtk"; version = "0.1.0"; version = "3.2.5"; src = fetchgit { url = "https://repo.dec05eba.com/gpu-screen-recorder-gtk"; rev = "4c317abd0531f8e155fbbbcd32850bbeebbf2ead"; sha256 = "sha256-5W6qmUMP31ndRDxMHuQ/XnZysPQgaie0vVlMTzfODU4="; src = fetchurl { url = "https://dec05eba.com/snapshot/gpu-screen-recorder-gtk.git.r175.cfd18af.tar.gz"; hash = "sha256-HhZe22Hm9yGoy5WoyuP2+Wj8E3nMs4uf96mzmP6CMqU="; }; patches = [ ./fix-nvfbc-check.patch ]; sourceRoot = "."; nativeBuildInputs = [ pkg-config makeWrapper wrapGAppsHook ]; buildInputs = [ gtk3 libX11 libXrandr libpulseaudio libdrm ]; buildPhase = '' Loading @@ -33,7 +41,9 @@ stdenv.mkDerivation rec { install -Dt $out/bin/ gpu-screen-recorder-gtk install -Dt $out/share/applications/ gpu-screen-recorder-gtk.desktop wrapProgram $out/bin/gpu-screen-recorder-gtk --prefix PATH : ${lib.makeBinPath [ gpu-screen-recorder ]} gappsWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ gpu-screen-recorder ]}) # we also append /run/opengl-driver/lib as it otherwise fails to find libcuda. gappsWrapperArgs+=(--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ libglvnd ]}:/run/opengl-driver/lib) ''; meta = with lib; { Loading
pkgs/top-level/all-packages.nix +1 −4 Original line number Diff line number Diff line Loading @@ -32297,10 +32297,7 @@ with pkgs; gpsprune = callPackage ../applications/misc/gpsprune { }; gpu-screen-recorder = callPackage ../applications/video/gpu-screen-recorder { # rm me as soon as this package gains the support for cuda 11 inherit (cudaPackages_10) cudatoolkit; }; gpu-screen-recorder = callPackage ../applications/video/gpu-screen-recorder { }; gpu-screen-recorder-gtk = callPackage ../applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix { };