2023-11-22 15:33:16 -05:00
|
|
|
{
|
|
|
|
pkgs,
|
2023-12-04 10:05:25 -05:00
|
|
|
config,
|
2023-11-22 15:33:16 -05:00
|
|
|
lib,
|
2023-12-31 15:44:53 -05:00
|
|
|
gpu-screen-recorder-src,
|
2023-11-22 15:33:16 -05:00
|
|
|
...
|
|
|
|
}: let
|
2024-02-16 16:41:10 -05:00
|
|
|
inherit (config.vars) mainUser mainMonitor;
|
|
|
|
inherit (lib) concatStringsSep removePrefix;
|
|
|
|
hyprPkgs = config.home-manager.users.${mainUser}.wayland.windowManager.hyprland.finalPackage;
|
2024-01-09 13:13:04 -05:00
|
|
|
|
2023-12-31 16:24:57 -05:00
|
|
|
gsr = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "gpu-screen-recorder";
|
2024-03-25 22:42:23 -04:00
|
|
|
version = gpu-screen-recorder-src.shortRev;
|
2023-12-31 15:44:53 -05:00
|
|
|
|
|
|
|
src = gpu-screen-recorder-src;
|
2023-11-13 00:03:28 -05:00
|
|
|
|
2023-12-31 16:24:57 -05:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
libpulseaudio
|
|
|
|
ffmpeg
|
|
|
|
wayland
|
|
|
|
libdrm
|
|
|
|
libva
|
|
|
|
xorg.libXcomposite
|
|
|
|
xorg.libXrandr
|
|
|
|
];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
./build.sh
|
|
|
|
'';
|
2023-11-13 00:03:28 -05:00
|
|
|
|
|
|
|
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"
|
2023-11-23 01:07:56 -05:00
|
|
|
#install -Dm644 "extra/gpu-screen-recorder.service" "$out/lib/systemd/user/gpu-screen-recorder.service"
|
2023-11-13 00:03:28 -05:00
|
|
|
|
|
|
|
wrapProgram $out/bin/gpu-screen-recorder --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [
|
|
|
|
pkgs.addOpenGLRunpath.driverLink
|
|
|
|
pkgs.libglvnd
|
|
|
|
]}"
|
|
|
|
'';
|
2023-12-31 16:24:57 -05:00
|
|
|
};
|
2023-11-13 00:03:28 -05:00
|
|
|
in {
|
|
|
|
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";
|
|
|
|
};
|
|
|
|
};
|
2023-12-04 10:05:25 -05:00
|
|
|
|
2024-01-09 13:13:04 -05:00
|
|
|
home-manager.users.${mainUser} = {
|
2024-05-05 23:07:06 -04:00
|
|
|
home.packages = [
|
2024-02-16 16:41:10 -05:00
|
|
|
gsr
|
|
|
|
|
2024-05-05 23:07:06 -04:00
|
|
|
(pkgs.writeShellApplication {
|
2024-02-16 16:41:10 -05:00
|
|
|
name = "gpu-save-replay";
|
2024-05-05 23:07:06 -04:00
|
|
|
runtimeInputs = [pkgs.procps];
|
2024-02-16 16:41:10 -05:00
|
|
|
text = ''
|
|
|
|
pkill --signal SIGUSR1 -f gpu-screen-recorder
|
2024-01-08 11:25:18 -05:00
|
|
|
'';
|
2024-02-16 16:41:10 -05:00
|
|
|
})
|
|
|
|
|
2024-05-05 23:07:06 -04:00
|
|
|
(pkgs.writeShellApplication {
|
2024-02-16 16:41:10 -05:00
|
|
|
name = "gsr-start";
|
2024-05-05 23:07:06 -04:00
|
|
|
runtimeInputs = [pkgs.pulseaudio hyprPkgs pkgs.xorg.xrandr];
|
2024-02-16 16:41:10 -05:00
|
|
|
text = ''
|
|
|
|
main="${removePrefix "desc:" mainMonitor}"
|
|
|
|
WINDOW=$(hyprctl -j monitors | jq '.[] |= (.description |= gsub(","; ""))' | jq -r ".[] | select(.description | test(\"$main\")) | .name")
|
|
|
|
|
|
|
|
# Fix fullscreen game resolution
|
|
|
|
xrandr --output "$WINDOW" --primary
|
|
|
|
|
|
|
|
gpu-screen-recorder ${concatStringsSep " " [
|
|
|
|
''-v no''
|
|
|
|
''-r 1200''
|
|
|
|
''-mf yes''
|
|
|
|
''-o /home/matt/Videos/Replay''
|
|
|
|
# Audio settings
|
|
|
|
''-ac aac''
|
|
|
|
''-a "$(pactl get-default-sink).monitor"''
|
|
|
|
''-a "$(pactl get-default-source)"''
|
|
|
|
# Video settings
|
|
|
|
''-w "$WINDOW"''
|
|
|
|
''-f 60''
|
|
|
|
''-c mkv''
|
|
|
|
''-k hevc''
|
|
|
|
''-q very_high''
|
|
|
|
]}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
|
|
|
wayland.windowManager.hyprland.settings = {
|
2024-03-24 20:30:17 -04:00
|
|
|
bind = [",F8, exec, ags -r 'GSR.saveReplay()'"];
|
2023-12-04 10:05:25 -05:00
|
|
|
};
|
|
|
|
};
|
2023-11-13 00:03:28 -05:00
|
|
|
}
|