diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 49261f9eed3c..2561cf449740 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -20276,6 +20276,12 @@ githubId = 2845239; name = "Tim Put"; }; + timschumi = { + email = "timschumi@gmx.de"; + github = "timschumi"; + githubId = 16820960; + name = "Tim Schumacher"; + }; timstott = { email = "stott.timothy@gmail.com"; github = "timstott"; diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 3465f3653db1..25c48fa93a01 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -205,6 +205,7 @@ ./programs/goldwarden.nix ./programs/gpaste.nix ./programs/gphoto2.nix + ./programs/gpu-screen-recorder.nix ./programs/haguichi.nix ./programs/hamster.nix ./programs/htop.nix diff --git a/nixos/modules/programs/gpu-screen-recorder.nix b/nixos/modules/programs/gpu-screen-recorder.nix new file mode 100644 index 000000000000..39d0e2545241 --- /dev/null +++ b/nixos/modules/programs/gpu-screen-recorder.nix @@ -0,0 +1,40 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.gpu-screen-recorder; + package = cfg.package.override { + inherit (config.security) wrapperDir; + }; +in { + options = { + programs.gpu-screen-recorder = { + package = lib.mkPackageOption pkgs "gpu-screen-recorder" {}; + + enable = lib.mkOption { + type = lib.types.bool; + default = false; + description = '' + Whether to install gpu-screen-recorder and generate setcap + wrappers for promptless recording. + ''; + }; + }; + }; + + config = lib.mkIf cfg.enable { + security.wrappers."gsr-kms-server" = { + owner = "root"; + group = "root"; + capabilities = "cap_sys_admin+ep"; + source = "${package}/bin/gsr-kms-server"; + }; + security.wrappers."gpu-screen-recorder" = { + owner = "root"; + group = "root"; + capabilities = "cap_sys_nice+ep"; + source = "${package}/bin/gpu-screen-recorder"; + }; + }; + + meta.maintainers = with lib.maintainers; [ timschumi ]; +} diff --git a/pkgs/applications/video/gpu-screen-recorder/0001-Don-t-install-systemd-unit-files-using-absolute-path.patch b/pkgs/applications/video/gpu-screen-recorder/0001-Don-t-install-systemd-unit-files-using-absolute-path.patch new file mode 100644 index 000000000000..1403d59b86ba --- /dev/null +++ b/pkgs/applications/video/gpu-screen-recorder/0001-Don-t-install-systemd-unit-files-using-absolute-path.patch @@ -0,0 +1,25 @@ +From cd8c6561079ee4c53b4bed390edd75a730ac685d Mon Sep 17 00:00:00 2001 +From: Tim Schumacher +Date: Thu, 4 Jul 2024 16:26:36 +0200 +Subject: [PATCH] Don't install systemd unit files using absolute paths + +--- + meson.build | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/meson.build b/meson.build +index a188f16..7807abe 100644 +--- a/meson.build ++++ b/meson.build +@@ -54,7 +54,7 @@ executable('gsr-kms-server', 'kms/server/kms_server.c', dependencies : dependenc + executable('gpu-screen-recorder', src, dependencies : dep, install : true) + + if get_option('systemd') == true +- install_data(files('extra/gpu-screen-recorder.service'), install_dir : '/usr/lib/systemd/user') ++ install_data(files('extra/gpu-screen-recorder.service'), install_dir : 'lib/systemd/user') + endif + + if get_option('capabilities') == true +-- +2.45.1 + diff --git a/pkgs/applications/video/gpu-screen-recorder/default.nix b/pkgs/applications/video/gpu-screen-recorder/default.nix index 101cb3af49dd..89fda1154232 100644 --- a/pkgs/applications/video/gpu-screen-recorder/default.nix +++ b/pkgs/applications/video/gpu-screen-recorder/default.nix @@ -2,6 +2,8 @@ , lib , fetchurl , makeWrapper +, meson +, ninja , pkg-config , libXcomposite , libpulseaudio @@ -10,24 +12,30 @@ , libdrm , libva , libglvnd +, libXdamage +, libXi , libXrandr , libXfixes +, wrapperDir ? "/run/wrappers/bin" }: stdenv.mkDerivation { pname = "gpu-screen-recorder"; - version = "unstable-2024-05-21"; + version = "unstable-2024-07-05"; + # Snapshot tarballs use the following versioning format: # 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.r594.e572073.tar.gz"; - hash = "sha256-MTBxhvkoyotmRUx1sRN/7ruXBYwIbOFQNdJHhZ3DdDk="; + url = "https://dec05eba.com/snapshot/gpu-screen-recorder.git.r641.48cd80f.tar.gz"; + hash = "sha256-hIEK8EYIxQTTiFePPZf4V0nsxqxkfcDeOG9GK9whn+0="; }; sourceRoot = "."; nativeBuildInputs = [ pkg-config makeWrapper + meson + ninja ]; buildInputs = [ @@ -37,20 +45,29 @@ stdenv.mkDerivation { wayland libdrm libva + libXdamage + libXi libXrandr libXfixes ]; - buildPhase = '' - ./build.sh - ''; + patches = [ + ./0001-Don-t-install-systemd-unit-files-using-absolute-path.patch + ]; + + mesonFlags = [ + "-Dsystemd=true" + + # Capabilities are handled by security.wrappers if possible. + "-Dcapabilities=false" + ]; 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 : ${wrapperDir} \ --suffix PATH : $out/bin ''; diff --git a/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix b/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix index 0fa023a9fc94..b0c19e80a0be 100644 --- a/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix +++ b/pkgs/applications/video/gpu-screen-recorder/gpu-screen-recorder-gtk.nix @@ -1,47 +1,62 @@ { stdenv , lib -, fetchgit +, fetchurl , pkg-config +, desktop-file-utils , makeWrapper +, meson +, ninja , gtk3 +, libayatana-appindicator , libpulseaudio , libdrm , gpu-screen-recorder , libglvnd +, libX11 +, libXrandr +, wayland , wrapGAppsHook3 +, wrapperDir ? "/run/wrappers/bin" }: stdenv.mkDerivation { pname = "gpu-screen-recorder-gtk"; - version = "3.7.6"; + version = "unstable-2024-07-05"; - src = fetchgit { - url = "https://repo.dec05eba.com/gpu-screen-recorder-gtk"; - rev = "cd777c1506e20514df4b97345e480051cbaf9693"; - hash = "sha256-ZBYYsW75tq8TaZp0F4v7YIHKHk/DFBIGy3X781ho2oE="; + # Snapshot tarballs use the following versioning format: + # 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-gtk.git.r311.c611c51.tar.gz"; + hash = "sha256-86EdmeZ2dlffSfJOrTVGPtYyL3j6DmCQIALX2rpeS1Y="; }; + sourceRoot = "."; nativeBuildInputs = [ + desktop-file-utils pkg-config makeWrapper + meson + ninja wrapGAppsHook3 ]; buildInputs = [ gtk3 + libayatana-appindicator libpulseaudio libdrm + libX11 + libXrandr + wayland ]; - buildPhase = '' - ./build.sh - ''; - - installPhase = '' - install -Dt $out/bin/ gpu-screen-recorder-gtk - install -Dt $out/share/applications/ gpu-screen-recorder-gtk.desktop - - gappsWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ gpu-screen-recorder ]}) + preFixup = let + gpu-screen-recorder-wrapped = gpu-screen-recorder.override { + inherit wrapperDir; + }; + in '' + gappsWrapperArgs+=(--prefix PATH : ${wrapperDir}) + gappsWrapperArgs+=(--suffix PATH : ${lib.makeBinPath [ gpu-screen-recorder-wrapped ]}) # 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) '';