SystemD units#

You should register any services that you’d like to start as a systemd unit by placing a unit file in /etc/local/systemd/<unit-name>.<type>.

A simple unit file to start a service may look like this:

Description=My Application Service




A few notes that you should pay attention to:

  • We do not enforce the user. You can start your services as root, but that may easily cause permission issues and poses severe security risk. Please confine your services to an appropriate user, typically your service user.

  • Your service should not daemonize / detach on its own. SystemD works best when you just start and stay attached in the foreground.

  • On NixOS the environment is quite clean and you may start just using the PATH as shown above.

  • We bind your units to the by default so they will be automatically started upon boot and stopped properly when the machine shuts down.

See the systemd.service and related manpages for further information.