Systemd user units are not started

So after I realized that you can just create systemd user units with the nixos configuration while also getting the paths right automatically, I wanted to create a simple service that handles mail fetching for me:

  # periodic automated mail fetching = {
    enable = true;
    description = "Automatically fetches for new mail when the network is up";
    after = [ "" ];
    wantedBy = [ "" ];
    serviceConfig = {
      Restart = "always";
      RestartSec = "60";
    path = with pkgs; [ bash notmuch isync ];
    script = ''
      mbsync -a && /home/felix/.config/neomutt/

But the issue is: Even though the is reached, the service is never started:

● - Network is Online
     Loaded: loaded (/nix/store/zpzn7c5g58srji21flwqmxzbnaa8w29j-systemd-246.6/example/systemd/system/; enabled; vendor preset: enabled)
    Drop-In: /nix/store/31q27y40ihb95g3gyl9ywvplsqm4vvyy-system-units/
     Active: active since Thu 2021-05-27 08:07:46 CEST; 36min ago
       Docs: man:systemd.special(7)

May 27 08:07:46 entropy systemd[1]: Reached target Network is Online.

Is there anything I’m doing wrong? How can I get the service to fire up automatically (without having to put a systemd user unit into my ~/.config/systemd/user folder manually)?

wantedBy = [ "" ];

A user service cannot depend on a system service. Has nothing to with NixOS.


Ugh, makes total sense. I guess my lacking systemd knowledge is to blame here. Thanks for taking the time to answer!