diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index fb9c8455c115f..5caf8ebffd5e6 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -232,6 +232,7 @@ ./programs/gnupg.nix ./programs/gpaste.nix ./programs/gphoto2.nix + ./programs/gpu-screen-recorder-ui.nix ./programs/gpu-screen-recorder.nix ./programs/haguichi.nix ./programs/hamster.nix diff --git a/nixos/modules/programs/gpu-screen-recorder-ui.nix b/nixos/modules/programs/gpu-screen-recorder-ui.nix new file mode 100644 index 0000000000000..a28dbc26c6299 --- /dev/null +++ b/nixos/modules/programs/gpu-screen-recorder-ui.nix @@ -0,0 +1,46 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + cfg = config.programs.gpu-screen-recorder-ui; + package = cfg.package.override { + inherit (config.security) wrapperDir; + }; +in +{ + options = { + programs.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/by-name/gp/gpu-screen-recorder-notification/package.nix b/pkgs/by-name/gp/gpu-screen-recorder-notification/package.nix new file mode 100644 index 0000000000000..8fb11fa809695 --- /dev/null +++ b/pkgs/by-name/gp/gpu-screen-recorder-notification/package.nix @@ -0,0 +1,61 @@ +{ + lib, + stdenv, + fetchgit, + pkg-config, + meson, + ninja, + libx11, + libxrender, + libxrandr, + libxext, + libglvnd, + wayland, + wayland-scanner, + gitUpdater, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "gpu-screen-recorder-notification"; + version = "1.1.0"; + + src = fetchgit { + url = "https://repo.dec05eba.com/gpu-screen-recorder-notification"; + tag = finalAttrs.version; + hash = "sha256-ODifZ046DEBNiGT3+S6pQyF8ekrb6LIHWton8nv1MBo="; + }; + + 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/gpu-screen-recorder-notification/about/"; + license = lib.licenses.gpl3Only; + mainProgram = "gsr-notify"; + maintainers = with lib.maintainers; [ js6pak ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/by-name/gp/gpu-screen-recorder-ui/package.nix b/pkgs/by-name/gp/gpu-screen-recorder-ui/package.nix new file mode 100644 index 0000000000000..0da5a0721f665 --- /dev/null +++ b/pkgs/by-name/gp/gpu-screen-recorder-ui/package.nix @@ -0,0 +1,108 @@ +{ + lib, + stdenv, + fetchgit, + pkg-config, + meson, + ninja, + makeWrapper, + gpu-screen-recorder, + gpu-screen-recorder-notification, + libx11, + libxrender, + libxrandr, + libxcomposite, + libxi, + libxcursor, + libglvnd, + libpulseaudio, + libdrm, + dbus, + wayland, + wayland-scanner, + wrapperDir ? "/run/wrappers/bin", + gitUpdater, +}: + +stdenv.mkDerivation (finalAttrs: { + pname = "gpu-screen-recorder-ui"; + version = "1.10.8"; + + src = fetchgit { + url = "https://repo.dec05eba.com/gpu-screen-recorder-ui"; + tag = finalAttrs.version; + hash = "sha256-x7MBTUWDKCzClq4ukgtFazOD/RLkX5lgmm9slN5BjVk="; + }; + + patches = [ + ./remove-gnome-postinstall.patch + ]; + + 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=gsr-ui" "ExecStart=$out/bin/gsr-ui" + + substituteInPlace gpu-screen-recorder.desktop \ + --replace-fail "Exec=gsr-ui" "Exec=$out/bin/gsr-ui" + ''; + + nativeBuildInputs = [ + pkg-config + meson + ninja + makeWrapper + ]; + + buildInputs = [ + libx11 + libxrender + libxrandr + libxcomposite + libxi + libxcursor + libglvnd + libpulseaudio + libdrm + dbus + 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/gsr-ui" \ + --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/gpu-screen-recorder-ui/about/"; + license = lib.licenses.gpl3Only; + mainProgram = "gsr-ui"; + maintainers = with lib.maintainers; [ js6pak ]; + platforms = lib.platforms.linux; + }; +}) diff --git a/pkgs/by-name/gp/gpu-screen-recorder-ui/remove-gnome-postinstall.patch b/pkgs/by-name/gp/gpu-screen-recorder-ui/remove-gnome-postinstall.patch new file mode 100644 index 0000000000000..f064a87de5d83 --- /dev/null +++ b/pkgs/by-name/gp/gpu-screen-recorder-ui/remove-gnome-postinstall.patch @@ -0,0 +1,14 @@ +diff --git a/meson.build b/meson.build +index cf16e81..7c3629d 100644 +--- a/meson.build ++++ b/meson.build +@@ -147,9 +147,6 @@ install_subdir('translations', install_dir : gsr_ui_resources_path) + if get_option('desktop-files') == true + install_data(files('gpu-screen-recorder.desktop'), install_dir : join_paths(prefix, datadir, 'applications')) + install_subdir('icons/hicolor', install_dir : icons_path) +- +- gnome = import('gnome') +- gnome.post_install(update_desktop_database : true) + endif + + if get_option('systemd') == true