1 { config, lib, pkgs, ... }:
6 cfg = config.services.replay-sorcery;
7 configFile = generators.toKeyValue {} cfg.settings;
10 options = with types; {
11 services.replay-sorcery = {
12 enable = mkEnableOption (lib.mdDoc "the ReplaySorcery service for instant-replays");
14 enableSysAdminCapability = mkEnableOption (lib.mdDoc ''
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'');
19 autoStart = mkOption {
22 description = lib.mdDoc "Automatically start ReplaySorcery when graphical-session.target starts.";
26 type = attrsOf (oneOf [ str int ]);
28 description = lib.mdDoc "System-wide configuration for ReplaySorcery (/etc/replay-sorcery.conf).";
29 example = literalExpression ''
31 videoInput = "hwaccel"; # requires `services.replay-sorcery.enableSysAdminCapability = true`
39 config = mkIf cfg.enable {
41 systemPackages = [ pkgs.replay-sorcery ];
42 etc."replay-sorcery.conf".text = configFile;
45 security.wrappers = mkIf cfg.enableSysAdminCapability {
49 capabilities = "cap_sys_admin+ep";
50 source = "${pkgs.replay-sorcery}/bin/replay-sorcery";
55 packages = [ pkgs.replay-sorcery ];
56 user.services.replay-sorcery = {
57 wantedBy = mkIf cfg.autoStart [ "graphical-session.target" ];
58 partOf = mkIf cfg.autoStart [ "graphical-session.target" ];
60 ExecStart = mkIf cfg.enableSysAdminCapability [
61 "" # Tell systemd to clear the existing ExecStart list, to prevent appending to it.
62 "${config.security.wrapperDir}/replay-sorcery"
70 maintainers = with maintainers; [ kira-bruneau ];