Add systemd specific config to (restic) service

I’ve set up regular (weekly) backups using services.restic.backups. Works mostly great except my setup still has some issues and sometimes it fails. I want to get a status report about this. I’m thinking sending a mail using msmtp.

According to my research, this should be easily set up if I controlled the entire systemd setup using systemd.services.<name>.postStop. However, the restic service does not seem to expose the underlying systemd interface and so I don’t see how I could make this work. Do you have any ideas?

Looking at the code for its NixOS module, it looks like it uses systemd.services."restic-backups-${name}". You might want to use unitConfig.OnFailure as in this example.

Check out this article in the section “Desktop notifications for failures”. It’s possible you’ll get some advice in it.