"clone" a systemd service in nixos config?

say I have a service enabled like services.emacs.enable = true in config. That should result in a systemd.user.services.emacs config being created. How can I refer to the latter so I can “clone” it somehow, eg systemd.user.services.another-emacs = ...?
(I guess I will use lib.attrsets.updateManyAttrsByPath to change the clone a bit once I know how to get it)

You have acces to all your configuration in the config attribute. For your example you can do this:

{ config, ...}:
systemd.user.services.another-emacs = config.systemd.user.services.emacs;
2 Likes

I haven’t tried it yet, I ended up manually copying then editing systemd.user.services.<name> myself because I wanted quite a few changes. Thanks