feat(binto): add gpu-screen-recorder module

This commit is contained in:
matt1432 2023-11-13 00:03:28 -05:00
parent 38c197dd87
commit c41f4121b0
4 changed files with 82 additions and 1 deletions

View file

@ -8,13 +8,14 @@
../../modules/tailscale.nix
./modules/desktop.nix
./modules/gpu-replay.nix
./modules/nix-gaming.nix
./modules/nvidia.nix
];
services.device-vars = {
username = "matt";
fontSize = 12.5;
fontSize = 10.0;
};
users.users.matt = {

View file

@ -1,4 +1,19 @@
{ ... }: {
# Disable compositor in X11 for best performance
# TODO: add mic sound
xdg.configFile."gpu-screen-recorder.env".text = ''
WINDOW=focused
CONTAINER=mp4
QUALITY=very_high
CODEC=auto
AUDIO_CODEC=opus
FRAMERATE=60
REPLAYDURATION=1200
OUTPUTDIR=/home/matt/Videos/Replay
MAKEFOLDERS=yes
ADDITIONAL_ARGS="-s 2560x1440"
'';
xdg.desktopEntries."com.github.iwalton3.jellyfin-media-player" = {
name = "Jellyfin Media Player";
comment = "Desktop client for Jellyfin";

View file

@ -18,6 +18,7 @@
p7zip # for reshade
xclip
wl-clipboard
vlc
flat-remix-icon-theme
nextcloud-client
libreoffice-qt

View file

@ -0,0 +1,64 @@
{ pkgs, lib, ... }: let
gsr = (pkgs.gpu-screen-recorder.overrideAttrs (o: {
src = pkgs.fetchgit {
url = "https://repo.dec05eba.com/gpu-screen-recorder";
rev = "1ac862d155e10f050e6f6cca5381f9f5a3528d98";
hash = "sha256-wLiBn4VIi+IWY4qVkdFzkHhECTFH97snogVTEwM5yx8=";
};
buildInputs = (o.buildInputs or [ ]) ++ (with pkgs; [
wayland
wayland-protocols
libdrm
libva
xorg.libXrandr
libglvnd
]);
postPatch = "";
installPhase = ''
strip gsr-kms-server
strip gpu-screen-recorder
install -Dm755 "gsr-kms-server" "$out/bin/gsr-kms-server"
install -Dm755 "gpu-screen-recorder" "$out/bin/gpu-screen-recorder"
install -Dm644 "extra/gpu-screen-recorder.service" "$out/lib/systemd/user/gpu-screen-recorder.service"
wrapProgram $out/bin/gpu-screen-recorder --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [
pkgs.addOpenGLRunpath.driverLink
pkgs.libglvnd
]}"
'';
}));
in {
environment.systemPackages = with pkgs; [
pulseaudio # for getting audio sink
gsr
(writeShellScriptBin "gpu-save-replay" ''
exec ${pkgs.procps}/bin/pkill --signal SIGUSR1 -f gpu-screen-recorder
'')
# Run this after login to make sure it works
(writeShellScriptBin "gpu-restart-replay" ''
exec systemctl --user restart gpu-screen-recorder.service
'')
];
security.wrappers = {
gpu-screen-recorder = {
owner = "root";
group = "video";
capabilities = "cap_sys_nice+ep";
source = "${gsr}/bin/gpu-screen-recorder";
};
gsr-kms-server = {
owner = "root";
group = "video";
capabilities = "cap_sys_admin+ep";
source = "${gsr}/bin/gsr-kms-server";
};
};
}