rtkit: 0.13 -> 0.14, refactor; nixos/rtkit: refactor (#470633)

This commit is contained in:
Sefa Eyeoglu
2026-01-03 14:26:08 +00:00
committed by GitHub
5 changed files with 44 additions and 162 deletions
+13 -23
View File
@@ -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,7 @@ in
description = "RealtimeKit daemon";
};
users.groups.rtkit = { };
};
meta = { inherit (pkgs.rtkit.meta) maintainers; };
}
@@ -1,22 +0,0 @@
From 7d62095b94f8df3891c984a1535026d2658bb177 Mon Sep 17 00:00:00 2001
From: Edmund Wu <fangkazuto@gmail.com>
Date: Sat, 11 Apr 2020 16:59:35 -0400
Subject: [PATCH] meson: actually use systemd_systemunitdir
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 02e6c73..ba5ba1e 100644
--- a/meson.build
+++ b/meson.build
@@ -58,7 +58,7 @@ if policydir == ''
policydir = get_option('datadir') / 'polkit-1' / 'actions'
endif
-systemunitdir = ''
+systemunitdir = get_option('systemd_systemunitdir')
if systemunitdir == '' and systemd_dep.found()
systemunitdir = systemd_dep.get_pkgconfig_variable(
'systemdsystemunitdir',
@@ -1,22 +0,0 @@
From 98f70edd8f534c371cb4308b9720739c5178918d Mon Sep 17 00:00:00 2001
From: Felipe Sateler <fsateler@users.noreply.github.com>
Date: Sat, 11 Apr 2020 10:59:21 -0400
Subject: [PATCH] meson: fix librt find_library check
---
meson.build | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index 02e6c73..49da472 100644
--- a/meson.build
+++ b/meson.build
@@ -22,7 +22,7 @@ polkit_dep = dependency('polkit-gobject-1', required: false)
systemd_dep = dependency('systemd', required: false)
thread_dep = dependency('threads')
-librt_dep = cc.find_library('z')
+librt_dep = cc.find_library('rt')
cc.check_header('sched.h', dependencies: librt_dep)
cc.has_function('sched_setscheduler', dependencies: librt_dep)
+31 -22
View File
@@ -1,7 +1,7 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchFromGitLab,
meson,
ninja,
pkg-config,
@@ -10,23 +10,28 @@
libcap,
polkit,
systemd,
fetchpatch,
nix-update-script,
}:
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "rtkit";
version = "0.13";
version = "0.14";
src = fetchFromGitHub {
owner = "heftig";
src = fetchFromGitLab {
domain = "gitlab.freedesktop.org";
owner = "pipewire";
repo = "rtkit";
rev = "c295fa849f52b487be6433e69e08b46251950399";
sha256 = "0yfsgi3pvg6dkizrww1jxpkvcbhzyw9110n1dypmzq0c5hlzjxcd";
tag = "v${finalAttrs.version}";
hash = "sha256-y952SHbUWIjg1BKqenHABVWm0S5d/sBac1zRp9BpXB8=";
};
patches = [
./meson-actual-use-systemd_systemunitdir.patch
./meson-fix-librt-find_library-check.patch
./rtkit-daemon-dont-log-debug-messages-by-default.patch
# Let us override the `sysusersdir` path
(fetchpatch {
url = "https://gitlab.freedesktop.org/pipewire/rtkit/-/commit/621fdc3f2c037781dc279760cfbff64974fdbe77.patch";
hash = "sha256-Ffdi6dfZmdBpClpJkPNISmEoeUkIufrObz5g7RSPqLw=";
})
];
nativeBuildInputs = [
@@ -35,6 +40,7 @@ stdenv.mkDerivation {
pkg-config
unixtools.xxd
];
buildInputs = [
dbus
libcap
@@ -43,23 +49,26 @@ stdenv.mkDerivation {
];
mesonFlags = [
"-Dinstalled_tests=false"
"-Ddbus_systemservicedir=${placeholder "out"}/share/dbus-1/system-services"
"-Ddbus_interfacedir=${placeholder "out"}/share/dbus-1/interfaces"
"-Ddbus_rulesdir=${placeholder "out"}/etc/dbus-1/system.d"
"-Dpolkit_actiondir=${placeholder "out"}/share/polkit-1/actions"
"-Dsystemd_systemunitdir=${placeholder "out"}/etc/systemd/system"
(lib.mesonBool "installed_tests" false)
(lib.mesonOption "dbus_systemservicedir" "${placeholder "out"}/share/dbus-1/system-services")
(lib.mesonOption "dbus_interfacedir" "${placeholder "out"}/share/dbus-1/interfaces")
(lib.mesonOption "dbus_rulesdir" "${placeholder "out"}/etc/dbus-1/system.d")
(lib.mesonOption "polkit_actiondir" "${placeholder "out"}/share/polkit-1/actions")
(lib.mesonOption "systemd_systemunitdir" "${placeholder "out"}/etc/systemd/system")
(lib.mesonOption "systemd_sysusersdir" "${placeholder "out"}/lib/sysusers.d")
];
passthru.updateScript = nix-update-script { };
meta = {
homepage = "https://github.com/heftig/rtkit";
homepage = "https://gitlab.freedesktop.org/pipewire/rtkit";
description = "Daemon that hands out real-time priority to processes";
mainProgram = "rtkitctl";
license = with lib.licenses; [
gpl3
bsd0
]; # lib is bsd license
gpl3Plus
mit
];
platforms = lib.platforms.linux;
maintainers = [ lib.maintainers.Gliczy ];
};
}
})
@@ -1,73 +0,0 @@
From 4880b9c67628a781bdb183dcdc69f12cb829817d Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Sat, 15 Apr 2023 11:53:27 +0200
Subject: [PATCH] rtkit-daemon: Don't log debug messages by default
The rtkit-daemon service is a lot more verbose than other services
when it doesn't have anything to do. Stop logging the debug messages
by default to avoid flooding the system log.
This addresses issue #22.
---
rtkit-daemon.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/rtkit-daemon.c b/rtkit-daemon.c
index 17122fa..0c5d814 100644
--- a/rtkit-daemon.c
+++ b/rtkit-daemon.c
@@ -154,6 +154,9 @@ static bool canary_demote_unknown = FALSE;
/* Log to stderr? */
static bool log_stderr = FALSE;
+/* Also log debugging messages? */
+static bool log_debug = FALSE;
+
/* Scheduling policy to use */
static int sched_policy = SCHED_RR;
@@ -1876,6 +1879,7 @@ enum {
ARG_CANARY_DEMOTE_UNKNOWN,
ARG_CANARY_REFUSE_SEC,
ARG_STDERR,
+ ARG_DEBUG,
ARG_INTROSPECT
};
@@ -1905,6 +1909,7 @@ static const struct option long_options[] = {
{ "canary-demote-unknown", no_argument, 0, ARG_CANARY_DEMOTE_UNKNOWN },
{ "canary-refuse-sec", required_argument, 0, ARG_CANARY_REFUSE_SEC },
{ "stderr", no_argument, 0, ARG_STDERR },
+ { "debug", no_argument, 0, ARG_DEBUG },
{ "introspect", no_argument, 0, ARG_INTROSPECT },
{ NULL, 0, 0, 0}
};
@@ -1933,6 +1938,7 @@ static void show_help(const char *exe) {
" --version Show version\n\n"
"OPTIONS:\n"
" --stderr Log to STDERR in addition to syslog\n"
+ " --debug Also log debugging mssages\n"
" --user-name=USER Run daemon as user (%s)\n\n"
" --scheduling-policy=(RR|FIFO) Choose scheduling policy (%s)\n"
" --our-realtime-priority=[%i..%i] Realtime priority for the daemon (%u)\n"
@@ -2222,6 +2228,10 @@ static int parse_command_line(int argc, char *argv[], int *ret) {
log_stderr = TRUE;
break;
+ case ARG_DEBUG:
+ log_debug = TRUE;
+ break;
+
case ARG_INTROSPECT:
fputs(introspect_xml, stdout);
*ret = 0;
@@ -2251,6 +2261,9 @@ static int parse_command_line(int argc, char *argv[], int *ret) {
return -1;
}
+ if (!log_debug)
+ setlogmask(LOG_UPTO(LOG_INFO));
+
assert(our_realtime_priority >= (unsigned) sched_get_priority_min(sched_policy));
assert(our_realtime_priority <= (unsigned) sched_get_priority_max(sched_policy));