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-01-09 13:13:04 -05:00
|
|
|
inherit (config.vars) mainUser;
|
|
|
|
|
2023-12-31 16:24:57 -05:00
|
|
|
gsr = pkgs.stdenv.mkDerivation {
|
|
|
|
name = "gpu-screen-recorder";
|
2023-12-31 15:44:53 -05:00
|
|
|
version = gpu-screen-recorder-src.rev;
|
|
|
|
|
|
|
|
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 {
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
pulseaudio # for getting audio sink
|
|
|
|
gsr
|
|
|
|
|
2023-12-27 16:17:28 -05:00
|
|
|
# TODO: add notif on success
|
2023-11-13 00:03:28 -05:00
|
|
|
(writeShellScriptBin "gpu-save-replay" ''
|
|
|
|
exec ${pkgs.procps}/bin/pkill --signal SIGUSR1 -f gpu-screen-recorder
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2023-12-12 21:36:37 -05:00
|
|
|
# Allow CUDA on boot
|
|
|
|
boot.kernelModules = ["nvidia-uvm"];
|
|
|
|
|
2023-11-13 00:03:28 -05:00
|
|
|
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} = {
|
2023-12-04 10:05:25 -05:00
|
|
|
# TODO: add mic sound
|
|
|
|
xdg.configFile."gsr.sh" = {
|
|
|
|
executable = true;
|
2024-01-08 11:25:18 -05:00
|
|
|
text =
|
|
|
|
/*
|
|
|
|
bash
|
|
|
|
*/
|
|
|
|
''
|
|
|
|
export WINDOW=DP-5
|
|
|
|
export CONTAINER=mkv
|
|
|
|
export QUALITY=very_high
|
|
|
|
export CODEC=auto
|
|
|
|
export AUDIO_CODEC=aac
|
|
|
|
export FRAMERATE=60
|
|
|
|
export REPLAYDURATION=1200
|
|
|
|
export OUTPUTDIR=/home/matt/Videos/Replay
|
|
|
|
export MAKEFOLDERS=yes
|
|
|
|
# export ADDITIONAL_ARGS=
|
2023-12-04 10:05:25 -05:00
|
|
|
|
2024-01-08 11:25:18 -05:00
|
|
|
# Disable compositor in X11 for best performance
|
|
|
|
exec /bin/sh -c 'AUDIO="''${AUDIO_DEVICE:-$(pactl get-default-sink).monitor}"; gpu-screen-recorder -v no -w $WINDOW -c $CONTAINER -q $QUALITY -k $CODEC -ac $AUDIO_CODEC -a "$AUDIO" -f $FRAMERATE -r $REPLAYDURATION -o "$OUTPUTDIR" -mf $MAKEFOLDERS $ADDITIONAL_ARGS'
|
|
|
|
'';
|
2023-12-04 10:05:25 -05:00
|
|
|
};
|
|
|
|
};
|
2023-11-13 00:03:28 -05:00
|
|
|
}
|