Services on macOS

Hi there,
(excuse my nooobishness in nix)

I’ve got stuck with trying to launch emacs as a background service on macOS.
Currently I’m trying to do it through home-manager, and after some digging, I’ve realized it’s only enabled for linux.
After some further digging, it seems like systemd service is only enabled for Linux, thus the above limitation makes sense.

Now, is this just a home-manager limitation, or is there no abstraction/implementation in Nix for launchd/launchctl which is a systemd equivalent on macOS?

nix-darwin has the capability of setting up launchd services,
but it
isn’t really integrated into home-manager in any way.

I think you can use home-manager as a nix-darwin module
(similar
to NixOS) though? I am not sure, as I have not tried it.

correct, the current services implementation almost exactly translates to systemd units

Yes, you can. It’s one of the benefits over using NixOS.

However, you will be limited to darwin-only compatible configuration, which is the beginning of this topic :slight_smile:

This may be possible, but currently it heavily relies on systemd utilities, with an almost 1 to 1 feature set.

You could probably try a way to “translate” it into a launchd compatible configuration, but it will probably be error prone and frustrating.

Thank you both so much!

I’ve been on the fence re: home-manager since beginning, and looks like I might have to look into nix-darwin.

That helps a lot, should solve the problem until I find a way to get work done completely in NixOS.

nix-darwin is definitely the way to go if you are running on MacOS. I’ve tested the emacs service and it’s working.
The nix-darwin installation instructions, should be pretty straightforward.
For my current setup, I use nix-darwin for launchd services and home-manager to configure the rest. They work really well together.
feel free to post again if you have a problem.