From 7277f92d0d263e330737be2675400afc99c68067 Mon Sep 17 00:00:00 2001 From: Minionflo Date: Wed, 29 Jul 2026 18:24:52 +0200 Subject: [PATCH 1/2] rbw: add systemd server for rbw-agent --- modules/programs/rbw.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/programs/rbw.nix b/modules/programs/rbw.nix index a7dda185d00d..caef9d55cccc 100644 --- a/modules/programs/rbw.nix +++ b/modules/programs/rbw.nix @@ -93,6 +93,19 @@ in managed by Home Manager. ''; }; + + systemd = { + enable = lib.mkOption { + type = lib.types.bool; + description = "run the rbw agent in systemd"; + default = true; + }; + targets = lib.mkOption { + type = lib.types.listOf lib.types.str; + description = "targets for the rbw systemd service"; + default = [ "default.target" ]; + }; + }; }; config = lib.mkIf cfg.enable { @@ -101,5 +114,20 @@ in home.file."${configDir}/rbw/config.json" = lib.mkIf (cfg.settings != null) { source = jsonFormat.generate "rbw-config.json" (lib.filterAttrs (_: v: v != null) cfg.settings); }; + + systemd.user.services.rbw-agent = lib.mkIf cfg.systemd.enable { + Service = { + ExecStart = "${cfg.package}/bin/rbw-agent --no-daemonize"; + PIDFile = "rbw/pidfile"; + }; + Install = { + WantedBy = cfg.systemd.targets; + }; + Unit = { + After = [ "network.target" ]; + Description = "rbw Agent"; + Documentation = "man:rbw-agent(1)"; + }; + }; }; } From ae0de5bfe04006be59afb9ad42cdb6707a2dd611 Mon Sep 17 00:00:00 2001 From: Minionflo Date: Wed, 29 Jul 2026 18:30:59 +0200 Subject: [PATCH 2/2] rbw: add option to use rbw as the SSH Agent --- modules/programs/rbw.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/modules/programs/rbw.nix b/modules/programs/rbw.nix index caef9d55cccc..40661fd3dc47 100644 --- a/modules/programs/rbw.nix +++ b/modules/programs/rbw.nix @@ -64,6 +64,7 @@ let configDir = if pkgs.stdenv.hostPlatform.isDarwin then "Library/Application Support" else config.xdg.configHome; + socketPath = "$XDG_RUNTIME_DIR/rbw/ssh-agent-socket"; in { meta.maintainers = with lib.maintainers; [ ambroisie ]; @@ -93,6 +94,11 @@ in managed by Home Manager. ''; }; + sshAgent = lib.mkOption { + type = lib.types.bool; + description = "rbw as an SSH Agent"; + default = false; + }; systemd = { enable = lib.mkOption { @@ -109,6 +115,10 @@ in }; config = lib.mkIf cfg.enable { + assertions = [ + (lib.hm.assertions.assertPlatform "programs.rbw.sshAgent" pkgs lib.platforms.linux) + ]; + home.packages = [ cfg.package ]; home.file."${configDir}/rbw/config.json" = lib.mkIf (cfg.settings != null) { @@ -129,5 +139,18 @@ in Documentation = "man:rbw-agent(1)"; }; }; + + sshAuthSock = lib.mkIf cfg.sshAgent { + enable = true; + systemd = { + socketProviderUnit = lib.mkIf cfg.systemd.enable "rbw-agent.service"; + }; + initialization = { + bash = "export SSH_AUTH_SOCK=${socketPath}"; + fish = "set -x SSH_AUTH_SOCK ${socketPath}"; + zsh = "export SSH_AUTH_SOCK=${socketPath}"; + nushell = "$env.SSH_AUTH_SOCK = ${socketPath}"; + }; + }; }; }