From e2f799314f1b0df896f200735d7a929a8b3ec9c0 Mon Sep 17 00:00:00 2001 From: Kopatz <7265381+Kropatz@users.noreply.github.com> Date: Tue, 27 May 2025 18:09:53 +0200 Subject: [PATCH] add shadowplay (basically) --- modules/graphical/default.nix | 1 + modules/graphical/gpu-screen-recorder-ui.nix | 46 +++++++++ pkgs/default.nix | 2 + .../default.nix | 61 ++++++++++++ pkgs/gpu-screen-recorder-ui/default.nix | 99 +++++++++++++++++++ systems/pc/configuration.nix | 1 + 6 files changed, 210 insertions(+) create mode 100644 modules/graphical/gpu-screen-recorder-ui.nix create mode 100644 pkgs/gpu-screen-recorder-notification/default.nix create mode 100644 pkgs/gpu-screen-recorder-ui/default.nix diff --git a/modules/graphical/default.nix b/modules/graphical/default.nix index a53e808..6a36132 100644 --- a/modules/graphical/default.nix +++ b/modules/graphical/default.nix @@ -27,5 +27,6 @@ ./xfce.nix ./basics.nix ./sway.nix + ./gpu-screen-recorder-ui.nix ]; } diff --git a/modules/graphical/gpu-screen-recorder-ui.nix b/modules/graphical/gpu-screen-recorder-ui.nix new file mode 100644 index 0000000..58e89cf --- /dev/null +++ b/modules/graphical/gpu-screen-recorder-ui.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.custom.graphical.gpu-screen-recorder-ui; + package = cfg.package.override { + inherit (config.security) wrapperDir; + }; +in +{ + options = { + custom.graphical.gpu-screen-recorder-ui = { + package = lib.mkPackageOption pkgs "gpu-screen-recorder-ui" { }; + + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether to install gpu-screen-recorder-ui and generate setcap + wrappers for global hotkeys. + ''; + }; + }; + }; + + config = lib.mkIf cfg.enable { + programs.gpu-screen-recorder.enable = lib.mkDefault true; + + environment.systemPackages = [ package ]; + + systemd.packages = [ package ]; + + security.wrappers."gsr-global-hotkeys" = { + owner = "root"; + group = "root"; + capabilities = "cap_setuid+ep"; + source = lib.getExe' package "gsr-global-hotkeys"; + }; + }; + + meta.maintainers = with lib.maintainers; [ js6pak ]; +} diff --git a/pkgs/default.nix b/pkgs/default.nix index bd84bb4..78547ff 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -13,4 +13,6 @@ mangal-patched = pkgs.callPackage ./mangal/default.nix { }; rdna4-lact = pkgs.callPackage ./lact/default.nix { }; csharp-ls-8 = pkgs.callPackage ./csharp-lsp/default.nix { }; + gpu-screen-recorder-ui = pkgs.callPackage ./gpu-screen-recorder-ui/default.nix { }; + gpu-screen-recorder-notification = pkgs.callPackage ./gpu-screen-recorder-notification/default.nix { }; } diff --git a/pkgs/gpu-screen-recorder-notification/default.nix b/pkgs/gpu-screen-recorder-notification/default.nix new file mode 100644 index 0000000..a9299f5 --- /dev/null +++ b/pkgs/gpu-screen-recorder-notification/default.nix @@ -0,0 +1,61 @@ +{ lib +, stdenv +, fetchgit +, pkg-config +, meson +, ninja +, libX11 +, libXrender +, libXrandr +, libXext +, libglvnd +, wayland +, wayland-scanner +, gitUpdater +, +}: + +stdenv.mkDerivation rec { + pname = "gpu-screen-recorder-notification"; + version = "1.0.7"; + + src = fetchgit { + url = "https://repo.dec05eba.com/${pname}"; + tag = version; + hash = "sha256-hdsbQewnqSJvWEW9HaFuVf6vDAY5CDCGxVFsxZJ4Yh8="; + }; + + postPatch = '' + substituteInPlace depends/mglpp/depends/mgl/src/gl.c \ + --replace-fail "libGL.so.1" "${lib.getLib libglvnd}/lib/libGL.so.1" \ + --replace-fail "libGLX.so.0" "${lib.getLib libglvnd}/lib/libGLX.so.0" \ + --replace-fail "libEGL.so.1" "${lib.getLib libglvnd}/lib/libEGL.so.1" + ''; + + nativeBuildInputs = [ + pkg-config + meson + ninja + ]; + + buildInputs = [ + libX11 + libXrender + libXrandr + libXext + libglvnd + wayland + wayland-scanner + ]; + + passthru.updateScript = gitUpdater { }; + + meta = { + description = "Notification in the style of ShadowPlay"; + homepage = "https://git.dec05eba.com/${pname}/about/"; + license = lib.licenses.gpl3Only; + mainProgram = "gsr-notify"; + maintainers = with lib.maintainers; [ js6pak ]; + platforms = lib.platforms.linux; + }; +} diff --git a/pkgs/gpu-screen-recorder-ui/default.nix b/pkgs/gpu-screen-recorder-ui/default.nix new file mode 100644 index 0000000..68539ff --- /dev/null +++ b/pkgs/gpu-screen-recorder-ui/default.nix @@ -0,0 +1,99 @@ +{ + lib, + stdenv, + fetchgit, + pkg-config, + meson, + ninja, + makeWrapper, + gpu-screen-recorder, + gpu-screen-recorder-notification, + libX11, + libXrender, + libXrandr, + libXcomposite, + libXi, + libXcursor, + libglvnd, + libpulseaudio, + libdrm, + wayland, + wayland-scanner, + wrapperDir ? "/run/wrappers/bin", + gitUpdater, +}: + +stdenv.mkDerivation rec { + pname = "gpu-screen-recorder-ui"; + version = "1.6.1"; + + src = fetchgit { + url = "https://repo.dec05eba.com/${pname}"; + tag = version; + hash = "sha256-HKUbxX6EXLR4N/ag7gLIqitxBRU+1aLtlqDiSS7LK5I="; + }; + + postPatch = '' + substituteInPlace depends/mglpp/depends/mgl/src/gl.c \ + --replace-fail "libGL.so.1" "${lib.getLib libglvnd}/lib/libGL.so.1" \ + --replace-fail "libGLX.so.0" "${lib.getLib libglvnd}/lib/libGLX.so.0" \ + --replace-fail "libEGL.so.1" "${lib.getLib libglvnd}/lib/libEGL.so.1" + + substituteInPlace extra/gpu-screen-recorder-ui.service \ + --replace-fail "ExecStart=${meta.mainProgram}" "ExecStart=$out/bin/${meta.mainProgram}" + ''; + + nativeBuildInputs = [ + pkg-config + meson + ninja + makeWrapper + ]; + + buildInputs = [ + libX11 + libXrender + libXrandr + libXcomposite + libXi + libXcursor + libglvnd + libpulseaudio + libdrm + wayland + wayland-scanner + ]; + + mesonFlags = [ + # Handled by the module + (lib.mesonBool "capabilities" false) + ]; + + postInstall = + let + gpu-screen-recorder-wrapped = gpu-screen-recorder.override { + inherit wrapperDir; + }; + in + '' + wrapProgram "$out/bin/${meta.mainProgram}" \ + --prefix PATH : "${wrapperDir}" \ + --suffix PATH : "${ + lib.makeBinPath [ + gpu-screen-recorder-wrapped + gpu-screen-recorder-notification + ] + }" + ''; + + passthru.updateScript = gitUpdater { }; + + meta = { + description = "Fullscreen overlay UI for GPU Screen Recorder in the style of ShadowPlay"; + homepage = "https://git.dec05eba.com/${pname}/about/"; + license = lib.licenses.gpl3Only; + mainProgram = "gsr-ui"; + maintainers = with lib.maintainers; [ js6pak ]; + platforms = lib.platforms.linux; + }; +} diff --git a/systems/pc/configuration.nix b/systems/pc/configuration.nix index 82cde2f..3b7f8b5 100644 --- a/systems/pc/configuration.nix +++ b/systems/pc/configuration.nix @@ -75,6 +75,7 @@ ime.enable = true; noise-supression.enable = true; obs.enable = true; + gpu-screen-recorder-ui.enable = true; #openrgb.enable = true; sddm.enable = true; nightlight.enable = true;