From 0a9de8d1592d6bedeaf8ae108ea76deb6327468e Mon Sep 17 00:00:00 2001 From: John Ogle Date: Mon, 29 Dec 2025 10:21:58 -0800 Subject: [PATCH] Fix rbw-agent launching from systemd services The rbw unlock systemd services were failing to launch the rbw-agent daemon due to two issues: 1. Missing RBW_AGENT environment variable - rbw looks for this variable to locate the agent binary, falling back to PATH lookup. Systemd user services have minimal environments without the necessary PATH. 2. Default KillMode=control-group - when the oneshot service completed, systemd was killing all processes in the cgroup including the daemonized agent. Fixed by: - Setting RBW_AGENT environment variable to explicit agent binary path - Using KillMode=process to only kill the main process, allowing the spawned agent daemon to persist after service completion --- home/roles/desktop/default.nix | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/home/roles/desktop/default.nix b/home/roles/desktop/default.nix index cee93b1..0de7491 100644 --- a/home/roles/desktop/default.nix +++ b/home/roles/desktop/default.nix @@ -90,7 +90,11 @@ in Service = { Type = "oneshot"; ExecStart = "${pkgs.rbw}/bin/rbw unlock"; - Environment = "PATH=${pkgs.rbw}/bin:/run/current-system/sw/bin"; + Environment = "RBW_AGENT=${pkgs.rbw}/bin/rbw-agent"; + # KillMode = "process" prevents systemd from killing the rbw-agent daemon + # when this oneshot service completes. The agent is spawned by rbw unlock + # and needs to persist after the service exits. + KillMode = "process"; }; Install = { WantedBy = [ "graphical-session.target" ]; @@ -105,7 +109,11 @@ in Service = { Type = "oneshot"; ExecStart = "${pkgs.rbw}/bin/rbw unlock"; - Environment = "PATH=${pkgs.rbw}/bin:/run/current-system/sw/bin"; + Environment = "RBW_AGENT=${pkgs.rbw}/bin/rbw-agent"; + # KillMode = "process" prevents systemd from killing the rbw-agent daemon + # when this oneshot service completes. The agent is spawned by rbw unlock + # and needs to persist after the service exits. + KillMode = "process"; }; Install = { WantedBy = [ "suspend.target" ];