2021-08-05 21:33:18 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.replay-sorcery;
|
|
|
|
configFile = generators.toKeyValue {} cfg.settings;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = with types; {
|
|
|
|
services.replay-sorcery = {
|
|
|
|
enable = mkEnableOption "the ReplaySorcery service for instant-replays";
|
|
|
|
|
|
|
|
enableSysAdminCapability = mkEnableOption ''
|
|
|
|
the system admin capability to support hardware accelerated
|
|
|
|
video capture. This is equivalent to running ReplaySorcery as
|
|
|
|
root, so use with caution'';
|
|
|
|
|
|
|
|
autoStart = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "Automatically start ReplaySorcery when graphical-session.target starts.";
|
2021-08-05 21:33:18 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = attrsOf (oneOf [ str int ]);
|
|
|
|
default = {};
|
2022-08-12 12:06:08 +00:00
|
|
|
description = lib.mdDoc "System-wide configuration for ReplaySorcery (/etc/replay-sorcery.conf).";
|
2021-10-06 13:57:05 +00:00
|
|
|
example = literalExpression ''
|
2021-08-05 21:33:18 +00: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-22 15:38:15 +00:00
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
2021-08-05 21:33:18 +00:00
|
|
|
capabilities = "cap_sys_admin+ep";
|
2021-09-22 15:38:15 +00:00
|
|
|
source = "${pkgs.replay-sorcery}/bin/replay-sorcery";
|
2021-08-05 21:33:18 +00: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 ];
|
|
|
|
};
|
|
|
|
}
|