Systemd service for ActivityWatch

I’m on NixOS 23.11 and I noticed that the nix module for ActivityWatch (an open source time/activity tracker) does not define a service and has limited configurability. I created this Home Manager module to address these issues.

My module includes a systemd service that starts ActivityWatch when the user logs in, and periodically cleans up ActivityWatch log files.

I have been using it for a week now and it seems to work fine, but I’m still pretty new to NixOS and Home Manager, so I’m not sure what’s the best approach to adopt fo sharing this configuration with other people. Should I convert this Home Manager module into a nix flake? Or rather add this code to the nix module for ActivityWatch and make a PR?

1 Like

Hmm, upstream deliberately does not create a systemd service for this, it’s intended to be started with a normal DE autostart: release archive doesn't contain systemd service · Issue #403 · ActivityWatch/activitywatch · GitHub

I’m also unsure about your cleanup script, that seems fairly custom.

While I personally also prefer using systemd for this kind of thing, I feel like NixOS modules usually stick to workflows supported upstream. Going outside of upstream’s intentions may both be confusing to users and also create additional maintenance burden for NixOS.

So personally, I’d err on the side of not adding this to nixpkgs. I don’t make the rules though, you can always make a PR.

Thanks for the link, I totally missed it.

The weird thing about the .desktop file they mention in the issue is that it should be installed on my machine (NixOS 23.11), but if I run this command I see a bunch of .desktop files but none is for ActivityWatch.

ls -l /run/current-system/sw/share/applications

Same thing if I open the Session and Startup GUI. For example I can see blueman-manager.desktop in the terminal and Blueman Applet in the GUI.