lol

nixos/replay-sorcery: add module

+93 -3
+1
nixos/modules/module-list.nix
··· 912 912 ./services/wayland/cage.nix 913 913 ./services/video/epgstation/default.nix 914 914 ./services/video/mirakurun.nix 915 + ./services/video/replay-sorcery.nix 915 916 ./services/web-apps/atlassian/confluence.nix 916 917 ./services/web-apps/atlassian/crowd.nix 917 918 ./services/web-apps/atlassian/jira.nix
+70
nixos/modules/services/video/replay-sorcery.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.replay-sorcery; 7 + configFile = generators.toKeyValue {} cfg.settings; 8 + in 9 + { 10 + options = with types; { 11 + services.replay-sorcery = { 12 + enable = mkEnableOption "the ReplaySorcery service for instant-replays"; 13 + 14 + enableSysAdminCapability = mkEnableOption '' 15 + the system admin capability to support hardware accelerated 16 + video capture. This is equivalent to running ReplaySorcery as 17 + root, so use with caution''; 18 + 19 + autoStart = mkOption { 20 + type = bool; 21 + default = false; 22 + description = "Automatically start ReplaySorcery when graphical-session.target starts."; 23 + }; 24 + 25 + settings = mkOption { 26 + type = attrsOf (oneOf [ str int ]); 27 + default = {}; 28 + description = "System-wide configuration for ReplaySorcery (/etc/replay-sorcery.conf)."; 29 + example = literalExample '' 30 + { 31 + videoInput = "hwaccel"; # requires `services.replay-sorcery.enableSysAdminCapability = true` 32 + videoFramerate = 60; 33 + } 34 + ''; 35 + }; 36 + }; 37 + }; 38 + 39 + config = mkIf cfg.enable { 40 + environment = { 41 + systemPackages = [ pkgs.replay-sorcery ]; 42 + etc."replay-sorcery.conf".text = configFile; 43 + }; 44 + 45 + security.wrappers = mkIf cfg.enableSysAdminCapability { 46 + replay-sorcery = { 47 + source = "${pkgs.replay-sorcery}/bin/replay-sorcery"; 48 + capabilities = "cap_sys_admin+ep"; 49 + }; 50 + }; 51 + 52 + systemd = { 53 + packages = [ pkgs.replay-sorcery ]; 54 + user.services.replay-sorcery = { 55 + wantedBy = mkIf cfg.autoStart [ "graphical-session.target" ]; 56 + partOf = mkIf cfg.autoStart [ "graphical-session.target" ]; 57 + serviceConfig = { 58 + ExecStart = mkIf cfg.enableSysAdminCapability [ 59 + "" # Tell systemd to clear the existing ExecStart list, to prevent appending to it. 60 + "${config.security.wrapperDir}/replay-sorcery" 61 + ]; 62 + }; 63 + }; 64 + }; 65 + }; 66 + 67 + meta = { 68 + maintainers = with maintainers; [ kira-bruneau ]; 69 + }; 70 + }
+9 -3
pkgs/tools/video/replay-sorcery/default.nix
··· 23 23 sha256 = "sha256-HPkSOwfwcg4jLUzKfqdXgLu7mgD5H4wb9d2BrqWQeHc="; 24 24 }; 25 25 26 - # Patch in libnotify if support is enabled. 27 - patches = lib.optional notifySupport (substituteAll { 26 + patches = [ 27 + # Use global config generated by NixOS (/etc/replay-sorcery.conf) 28 + # instead of $out/etc/replay-sorcery.conf. 29 + ./fix-global-config.patch 30 + ] ++ lib.optional notifySupport (substituteAll { 31 + # Patch in libnotify if support is enabled. Can't use makeWrapper 32 + # since it would break the security wrapper in the NixOS module. 28 33 src = ./hardcode-libnotify.patch; 29 34 inherit libnotify; 30 35 }); ··· 42 47 "-DRS_SYSTEMD_DIR=${placeholder "out"}/lib/systemd/user" 43 48 44 49 # SETUID & SETGID permissions required for hardware accelerated 45 - # video capture can't be set during the build. 50 + # video capture can't be set during the build. Use the NixOS 51 + # module if you want hardware accelerated video capture. 46 52 "-DRS_SETID=OFF" 47 53 ]; 48 54
+13
pkgs/tools/video/replay-sorcery/fix-global-config.patch
··· 1 + diff --git a/src/rsbuild.h.in b/src/rsbuild.h.in 2 + index ff0a0f6..5529556 100644 3 + --- a/src/rsbuild.h.in 4 + +++ b/src/rsbuild.h.in 5 + @@ -20,7 +20,7 @@ 6 + #ifndef RS_BUILD_H 7 + #define RS_BUILD_H 8 + 9 + -#define RS_BUILD_GLOBAL_CONFIG "@CMAKE_INSTALL_PREFIX@/etc/replay-sorcery.conf" 10 + +#define RS_BUILD_GLOBAL_CONFIG "/etc/replay-sorcery.conf" 11 + #define RS_BUILD_LOCAL_CONFIG "%s/.config/replay-sorcery.conf" 12 + 13 + #cmakedefine RS_BUILD_PTHREAD_FOUND