2021-05-15 00:01:02 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.replay-sorcery;
|
|
|
|
configFile = generators.toKeyValue {} cfg.settings;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = with types; {
|
|
|
|
services.replay-sorcery = {
|
2022-08-28 21:18:44 +02:00
|
|
|
enable = mkEnableOption (lib.mdDoc "the ReplaySorcery service for instant-replays");
|
2021-05-15 00:01:02 +02:00
|
|
|
|
2022-08-28 21:18:44 +02:00
|
|
|
enableSysAdminCapability = mkEnableOption (lib.mdDoc ''
|
2021-05-15 00:01:02 +02:00
|
|
|
the system admin capability to support hardware accelerated
|
|
|
|
video capture. This is equivalent to running ReplaySorcery as
|
2022-08-28 21:18:44 +02:00
|
|
|
root, so use with caution'');
|
2021-05-15 00:01:02 +02:00
|
|
|
|
|
|
|
autoStart = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "Automatically start ReplaySorcery when graphical-session.target starts.";
|
2021-05-15 00:01:02 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = attrsOf (oneOf [ str int ]);
|
|
|
|
default = {};
|
2022-07-28 23:19:15 +02:00
|
|
|
description = lib.mdDoc "System-wide configuration for ReplaySorcery (/etc/replay-sorcery.conf).";
|
2021-10-03 18:06:03 +02:00
|
|
|
example = literalExpression ''
|
2021-05-15 00:01:02 +02:00
|
|
|
{
|
|
|
|
videoInput = "hwaccel"; # requires `services.replay-sorcery.enableSysAdminCapability = true`
|
|
|
|
videoFramerate = 60;
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
environment = {
|
|
|
|
systemPackages = [ pkgs.replay-sorcery ];
|
|
|
|
etc."replay-sorcery.conf".text = configFile;
|
|
|
|
};
|
|
|
|
|
|
|
|
security.wrappers = mkIf cfg.enableSysAdminCapability {
|
|
|
|
replay-sorcery = {
|
2021-09-12 18:53:48 +02:00
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
2021-05-15 00:01:02 +02:00
|
|
|
capabilities = "cap_sys_admin+ep";
|
2021-09-12 18:53:48 +02:00
|
|
|
source = "${pkgs.replay-sorcery}/bin/replay-sorcery";
|
2021-05-15 00:01:02 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd = {
|
|
|
|
packages = [ pkgs.replay-sorcery ];
|
|
|
|
user.services.replay-sorcery = {
|
|
|
|
wantedBy = mkIf cfg.autoStart [ "graphical-session.target" ];
|
|
|
|
partOf = mkIf cfg.autoStart [ "graphical-session.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = mkIf cfg.enableSysAdminCapability [
|
|
|
|
"" # Tell systemd to clear the existing ExecStart list, to prevent appending to it.
|
|
|
|
"${config.security.wrapperDir}/replay-sorcery"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
maintainers = with maintainers; [ kira-bruneau ];
|
|
|
|
};
|
|
|
|
}
|