From 1644a30ce04a9d74f897bdd98490e6c9538839b9 Mon Sep 17 00:00:00 2001 From: Antoine Martin Date: Mon, 11 Apr 2022 17:15:32 +0200 Subject: [PATCH] home: rbw: add a service --- home/rbw.nix | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/home/rbw.nix b/home/rbw.nix index 98ca2b0..10d2178 100644 --- a/home/rbw.nix +++ b/home/rbw.nix @@ -25,5 +25,28 @@ in { pinentry = pkgs.pinentry-gnome; }; }; + + # `rbw-agent` should be launched on first call to `rbw`, so this shouldn't + # be necessary. + # + # However, if for instance `rbw` if first called by the emacs-daemon (when + # accessing an IMAP account password), then restarting the user service + # associated to the emacs daemon also kills the rbw-agent it spawned, + # resetting the lock status and prompting for a passphrase again. + # + # This user service makes sure the rbw-agent is started when the user + # session launches. + systemd.user.services.rbw = { + Unit.Description = "rbw agent autostart"; + + Install.WantedBy = ["default.target"]; + + Service = { + ExecStart = "${pkgs.rbw}/bin/rbw-agent"; + Restart = "on-abort"; + Type = "forking"; + PIDFile = "%t/rbw/pidfile"; + }; + }; }; }