about summary refs log tree commit diff
path: root/pkgs/tools/video
diff options
context:
space:
mode:
authordavidak <davidak@users.noreply.github.com>2021-08-03 07:44:35 +0200
committerGitHub <noreply@github.com>2021-08-03 07:44:35 +0200
commitbd27e2e8316ac6eab11aa35c586e743286f23ecf (patch)
tree5d8292cbe52e2bdae9165a21c47f75b058cd6531 /pkgs/tools/video
parentf87f6fbf0de58b6ac221b80331c31abcd135a805 (diff)
parentb6e764bd6824422b6fcf949d24a1dfc7687bbc68 (diff)
Merge pull request #123045 from kira-bruneau/replay-sorcery
replay-sorcery: init at 0.5.0
Diffstat (limited to 'pkgs/tools/video')
-rw-r--r--pkgs/tools/video/replay-sorcery/default.nix62
-rw-r--r--pkgs/tools/video/replay-sorcery/fix-global-config.patch13
-rw-r--r--pkgs/tools/video/replay-sorcery/hardcode-libnotify.patch25
3 files changed, 100 insertions, 0 deletions
diff --git a/pkgs/tools/video/replay-sorcery/default.nix b/pkgs/tools/video/replay-sorcery/default.nix
new file mode 100644
index 0000000000000..8f362c3beb96e
--- /dev/null
+++ b/pkgs/tools/video/replay-sorcery/default.nix
@@ -0,0 +1,62 @@
+{ lib
+, stdenv
+, fetchFromGitHub
+, substituteAll
+, cmake
+, pkg-config
+, ffmpeg
+, libX11
+, drmSupport ? true, libdrm
+, notifySupport ? true, libnotify
+, pulseaudioSupport ? true, libpulseaudio
+}:
+
+stdenv.mkDerivation rec {
+  pname = "replay-sorcery";
+  version = "0.5.0";
+
+  src = fetchFromGitHub {
+    owner = "matanui159";
+    repo = "ReplaySorcery";
+    rev = version;
+    fetchSubmodules = true;
+    sha256 = "sha256-HPkSOwfwcg4jLUzKfqdXgLu7mgD5H4wb9d2BrqWQeHc=";
+  };
+
+  patches = [
+    # Use global config generated by NixOS (/etc/replay-sorcery.conf)
+    # instead of $out/etc/replay-sorcery.conf.
+    ./fix-global-config.patch
+  ] ++ lib.optional notifySupport (substituteAll {
+    # Patch in libnotify if support is enabled. Can't use makeWrapper
+    # since it would break the security wrapper in the NixOS module.
+    src = ./hardcode-libnotify.patch;
+    inherit libnotify;
+  });
+
+  nativeBuildInputs = [
+    cmake
+    pkg-config
+  ];
+
+  buildInputs = [ ffmpeg libX11 ]
+  ++ lib.optional drmSupport libdrm
+  ++ lib.optional pulseaudioSupport libpulseaudio;
+
+  cmakeFlags = [
+    "-DRS_SYSTEMD_DIR=${placeholder "out"}/lib/systemd/user"
+
+    # SETUID & SETGID permissions required for hardware accelerated
+    # video capture can't be set during the build. Use the NixOS
+    # module if you want hardware accelerated video capture.
+    "-DRS_SETID=OFF"
+  ];
+
+  meta = with lib; {
+    description = "An open-source, instant-replay solution for Linux";
+    homepage = "https://github.com/matanui159/ReplaySorcery";
+    license = licenses.gpl3Plus;
+    maintainers = with maintainers; [ kira-bruneau ];
+    platforms = platforms.linux;
+  };
+}
diff --git a/pkgs/tools/video/replay-sorcery/fix-global-config.patch b/pkgs/tools/video/replay-sorcery/fix-global-config.patch
new file mode 100644
index 0000000000000..4f30e2875cf72
--- /dev/null
+++ b/pkgs/tools/video/replay-sorcery/fix-global-config.patch
@@ -0,0 +1,13 @@
+diff --git a/src/rsbuild.h.in b/src/rsbuild.h.in
+index ff0a0f6..5529556 100644
+--- a/src/rsbuild.h.in
++++ b/src/rsbuild.h.in
+@@ -20,7 +20,7 @@
+ #ifndef RS_BUILD_H
+ #define RS_BUILD_H
+ 
+-#define RS_BUILD_GLOBAL_CONFIG "@CMAKE_INSTALL_PREFIX@/etc/replay-sorcery.conf"
++#define RS_BUILD_GLOBAL_CONFIG "/etc/replay-sorcery.conf"
+ #define RS_BUILD_LOCAL_CONFIG "%s/.config/replay-sorcery.conf"
+ 
+ #cmakedefine RS_BUILD_PTHREAD_FOUND
diff --git a/pkgs/tools/video/replay-sorcery/hardcode-libnotify.patch b/pkgs/tools/video/replay-sorcery/hardcode-libnotify.patch
new file mode 100644
index 0000000000000..8ff42bec92fa7
--- /dev/null
+++ b/pkgs/tools/video/replay-sorcery/hardcode-libnotify.patch
@@ -0,0 +1,25 @@
+diff --git a/src/config.c b/src/config.c
+index 3af7455..12cb6b5 100644
+--- a/src/config.c
++++ b/src/config.c
+@@ -129,7 +129,7 @@ static const AVOption configOptions[] = {
+     CONFIG_CONST(alt, RS_CONFIG_KEYMOD_ALT, keyMods),
+     CONFIG_CONST(super, RS_CONFIG_KEYMOD_SUPER, keyMods),
+     CONFIG_STRING(outputFile, "~/Videos/ReplaySorcery_%F_%H-%M-%S.mp4"),
+-    CONFIG_STRING(outputCommand, "notify-send " RS_NAME " \"Saved replay as %s\""),
++    CONFIG_STRING(outputCommand, "@libnotify@/bin/notify-send " RS_NAME " \"Saved replay as %s\""),
+     {NULL}};
+ 
+ static const AVClass configClass = {
+diff --git a/sys/replay-sorcery.conf b/sys/replay-sorcery.conf
+index 5cd0aa6..c600e7f 100644
+--- a/sys/replay-sorcery.conf
++++ b/sys/replay-sorcery.conf
+@@ -123,5 +123,5 @@ outputFile = ~/Videos/ReplaySorcery_%F_%H-%M-%S.mp4
+ 
+ # A command to run when a video is successfully saved
+ # Possible values: a printf formatted command
+-# Default value: notify-send ReplaySorcery "Saved replay as %s"
+-outputCommand = notify-send ReplaySorcery "Saved replay as %s"
++# Default value: @libnotify@/bin/notify-send ReplaySorcery "Saved replay as %s"
++outputCommand = @libnotify@/bin/notify-send ReplaySorcery "Saved replay as %s"