From 9b4104ca85fe0e4e7f1e92fa9e0fa29ab19bbde8 Mon Sep 17 00:00:00 2001 From: Gliczy <129636582+Gliczy@users.noreply.github.com> Date: Sun, 14 Dec 2025 07:02:33 +0100 Subject: [PATCH] nixos/rtkit: refactor --- nixos/modules/security/rtkit.nix | 36 +++++++++++--------------------- 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/nixos/modules/security/rtkit.nix b/nixos/modules/security/rtkit.nix index f2cd256468da..3775991b5f26 100644 --- a/nixos/modules/security/rtkit.nix +++ b/nixos/modules/security/rtkit.nix @@ -1,6 +1,3 @@ -# 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 = { }; - }; - }