2011-07-26 14:14:10 +00:00
|
|
|
|
# A module for ‘rtkit’, a DBus system service that hands out realtime
|
|
|
|
|
# scheduling priority to processes that ask for it.
|
|
|
|
|
|
2024-03-28 16:05:41 +08:00
|
|
|
|
{
|
|
|
|
|
config,
|
|
|
|
|
lib,
|
|
|
|
|
pkgs,
|
|
|
|
|
utils,
|
|
|
|
|
...
|
|
|
|
|
}:
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
2014-04-14 16:26:48 +02:00
|
|
|
|
with lib;
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
2024-03-28 16:05:41 +08:00
|
|
|
|
let
|
|
|
|
|
cfg = config.security.rtkit;
|
|
|
|
|
package = pkgs.rtkit;
|
|
|
|
|
|
|
|
|
|
in
|
|
|
|
|
{
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
|
|
|
|
options = {
|
2011-09-14 18:20:50 +00:00
|
|
|
|
|
2011-07-26 14:14:10 +00:00
|
|
|
|
security.rtkit.enable = mkOption {
|
2013-10-30 17:37:45 +01:00
|
|
|
|
type = types.bool;
|
2011-07-26 14:14:10 +00:00
|
|
|
|
default = false;
|
|
|
|
|
description = ''
|
|
|
|
|
Whether to enable the RealtimeKit system service, which hands
|
|
|
|
|
out realtime scheduling priority to user processes on
|
2024-12-10 22:27:05 +01:00
|
|
|
|
demand. For example, PulseAudio and PipeWire use this to
|
2011-07-26 14:14:10 +00:00
|
|
|
|
acquire realtime priority.
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-03-28 16:05:41 +08:00
|
|
|
|
security.rtkit.args = mkOption {
|
|
|
|
|
type = types.listOf types.str;
|
|
|
|
|
default = [ ];
|
|
|
|
|
description = ''
|
|
|
|
|
Command-line options for `rtkit-daemon`.
|
|
|
|
|
'';
|
|
|
|
|
example = [
|
|
|
|
|
"--our-realtime-priority=29"
|
|
|
|
|
"--max-realtime-priority=28"
|
|
|
|
|
];
|
|
|
|
|
};
|
|
|
|
|
|
2011-07-26 14:14:10 +00:00
|
|
|
|
};
|
2011-09-14 18:20:50 +00:00
|
|
|
|
|
2024-03-28 16:05:41 +08:00
|
|
|
|
config = mkIf cfg.enable {
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
2014-04-18 12:21:20 +02:00
|
|
|
|
security.polkit.enable = true;
|
|
|
|
|
|
|
|
|
|
# To make polkit pickup rtkit policies
|
2024-03-28 16:05:41 +08:00
|
|
|
|
environment.systemPackages = [ package ];
|
|
|
|
|
|
|
|
|
|
services.dbus.packages = [ package ];
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
2024-03-28 16:05:41 +08:00
|
|
|
|
systemd.packages = [ package ];
|
2014-04-18 12:21:20 +02:00
|
|
|
|
|
2024-03-28 16:05:41 +08:00
|
|
|
|
systemd.services.rtkit-daemon = {
|
|
|
|
|
serviceConfig.ExecStart = [
|
|
|
|
|
"" # Resets command from upstream unit.
|
|
|
|
|
"${package}/libexec/rtkit-daemon ${utils.escapeSystemdExecArgs cfg.args}"
|
|
|
|
|
];
|
|
|
|
|
};
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
2019-09-14 19:51:29 +02:00
|
|
|
|
users.users.rtkit = {
|
2021-08-08 12:00:00 +00:00
|
|
|
|
isSystemUser = true;
|
|
|
|
|
group = "rtkit";
|
2011-07-26 14:14:10 +00:00
|
|
|
|
description = "RealtimeKit daemon";
|
|
|
|
|
};
|
2021-08-08 12:00:00 +00:00
|
|
|
|
users.groups.rtkit = { };
|
2011-07-26 14:14:10 +00:00
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|