From 0193a0de27e509ab4cbd23150b3cdd9140504e85 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 4 Jul 2024 14:20:17 +0200 Subject: [PATCH 1/5] gpu-screen-recorder: unstable-2024-05-21 -> unstable-2024-07-05 --- .../video/gpu-screen-recorder/default.nix | 26 ++++++++++++++----- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/video/gpu-screen-recorder/default.nix b/pkgs/applications/video/gpu-screen-recorder/default.nix index 101cb3af49dd..63afa31a489a 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,29 @@ , libdrm , libva , libglvnd +, libXdamage +, libXi , libXrandr , libXfixes }: 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,16 +44,21 @@ stdenv.mkDerivation { wayland libdrm libva + libXdamage + libXi libXrandr libXfixes ]; - buildPhase = '' - ./build.sh - ''; + mesonFlags = [ + # FIXME: systemd unit file gets installed to absolute path. + "-Dsystemd=false" + + # FIXME: Capabilities can not be set if not running the build with root permissions. + "-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" \ From 223ea67b951a1e11ed71f38e66f1dfea5cb363e8 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 4 Jul 2024 16:28:46 +0200 Subject: [PATCH 2/5] gpu-screen-recorder: Enable installing systemd user units --- ...stemd-unit-files-using-absolute-path.patch | 25 +++++++++++++++++++ .../video/gpu-screen-recorder/default.nix | 7 ++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 pkgs/applications/video/gpu-screen-recorder/0001-Don-t-install-systemd-unit-files-using-absolute-path.patch 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 63afa31a489a..1e97afa4a7d1 100644 --- a/pkgs/applications/video/gpu-screen-recorder/default.nix +++ b/pkgs/applications/video/gpu-screen-recorder/default.nix @@ -50,9 +50,12 @@ stdenv.mkDerivation { libXfixes ]; + patches = [ + ./0001-Don-t-install-systemd-unit-files-using-absolute-path.patch + ]; + mesonFlags = [ - # FIXME: systemd unit file gets installed to absolute path. - "-Dsystemd=false" + "-Dsystemd=true" # FIXME: Capabilities can not be set if not running the build with root permissions. "-Dcapabilities=false" From 8e3320adfbf4f5b564a89839bcab105d7daf498d Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Thu, 4 Jul 2024 23:19:10 +0200 Subject: [PATCH 3/5] maintainers: add timschumi --- maintainers/maintainer-list.nix | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 7eb2f0d8e4ed..41a2f53c936f 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -20170,6 +20170,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"; From cddf0244b34d311967dfe2996aaf9989ee509835 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 5 Jul 2024 00:02:21 +0200 Subject: [PATCH 4/5] gpu-screen-recorder: Add program module for creating setcap wrappers Co-authored-by: oddlama Co-authored-by: ash --- nixos/modules/module-list.nix | 1 + .../modules/programs/gpu-screen-recorder.nix | 40 +++++++++++++++++++ .../video/gpu-screen-recorder/default.nix | 4 +- .../gpu-screen-recorder-gtk.nix | 10 ++++- 4 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 nixos/modules/programs/gpu-screen-recorder.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index b4c9faeef29e..ef6c2c427d55 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -204,6 +204,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/default.nix b/pkgs/applications/video/gpu-screen-recorder/default.nix index 1e97afa4a7d1..89fda1154232 100644 --- a/pkgs/applications/video/gpu-screen-recorder/default.nix +++ b/pkgs/applications/video/gpu-screen-recorder/default.nix @@ -16,6 +16,7 @@ , libXi , libXrandr , libXfixes +, wrapperDir ? "/run/wrappers/bin" }: stdenv.mkDerivation { @@ -57,7 +58,7 @@ stdenv.mkDerivation { mesonFlags = [ "-Dsystemd=true" - # FIXME: Capabilities can not be set if not running the build with root permissions. + # Capabilities are handled by security.wrappers if possible. "-Dcapabilities=false" ]; @@ -66,6 +67,7 @@ stdenv.mkDerivation { 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..2cb59cab4852 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 @@ -9,6 +9,7 @@ , gpu-screen-recorder , libglvnd , wrapGAppsHook3 +, wrapperDir ? "/run/wrappers/bin" }: stdenv.mkDerivation { @@ -37,11 +38,16 @@ stdenv.mkDerivation { ./build.sh ''; - installPhase = '' + installPhase = let + gpu-screen-recorder-wrapped = gpu-screen-recorder.override { + inherit wrapperDir; + }; + in '' 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 ]}) + 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) ''; From c1c9d38eba14582972f267ede4780f4520a3a34b Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Fri, 5 Jul 2024 22:39:27 +0200 Subject: [PATCH 5/5] gpu-screen-recorder-gtk: 3.7.6 -> unstable-2024-07-05 --- .../gpu-screen-recorder-gtk.nix | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) 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 2cb59cab4852..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,51 +1,60 @@ { 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 = let + preFixup = let gpu-screen-recorder-wrapped = gpu-screen-recorder.override { inherit wrapperDir; }; in '' - install -Dt $out/bin/ gpu-screen-recorder-gtk - install -Dt $out/share/applications/ gpu-screen-recorder-gtk.desktop - 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.