Commit 9b4104ca authored by Gliczy's avatar Gliczy
Browse files

nixos/rtkit: refactor

parent c4e897a5
Loading
Loading
Loading
Loading
+12 −24
Original line number Diff line number Diff line
# A module for ‘rtkit’, a DBus system service that hands out realtime
# scheduling priority to processes that ask for it.

{
  config,
  lib,
@@ -8,20 +5,13 @@
  utils,
  ...
}:

with lib;

let
  cfg = config.security.rtkit;
  package = pkgs.rtkit;

in
{

  options = {

    security.rtkit.enable = mkOption {
      type = types.bool;
  options.security.rtkit = {
    enable = lib.mkOption {
      type = lib.types.bool;
      default = false;
      description = ''
        Whether to enable the RealtimeKit system service, which hands
@@ -31,8 +21,10 @@ in
      '';
    };

    security.rtkit.args = mkOption {
      type = types.listOf types.str;
    package = lib.mkPackageOption pkgs "rtkit" { };

    args = lib.mkOption {
      type = lib.types.listOf lib.types.str;
      default = [ ];
      description = ''
        Command-line options for `rtkit-daemon`.
@@ -42,25 +34,23 @@ in
        "--max-realtime-priority=28"
      ];
    };

  };

  config = mkIf cfg.enable {

  config = lib.mkIf cfg.enable {
    security.polkit.enable = true;

    # To make polkit pickup rtkit policies
    environment.systemPackages = [ package ];
    environment.systemPackages = [ cfg.package ];

    services.dbus.packages = [ package ];
    services.dbus.packages = [ cfg.package ];

    systemd.packages = [ package ];
    systemd.packages = [ cfg.package ];

    systemd.services.rtkit-daemon = {
      serviceConfig = {
        ExecStart = [
          "" # Resets command from upstream unit.
          "${package}/libexec/rtkit-daemon ${utils.escapeSystemdExecArgs cfg.args}"
          "${cfg.package}/libexec/rtkit-daemon ${utils.escapeSystemdExecArgs cfg.args}"
        ];

        # Needs to verify the user of the processes.
@@ -104,7 +94,5 @@ in
      description = "RealtimeKit daemon";
    };
    users.groups.rtkit = { };

  };

}