English French
For further details see the https://www.freedesktop.org/software/systemd/man/systemd.exec.html[systemd.exec(5)] man page.
Packaging
Filesystem locations
Packages with systemd unit files *must* put them into `+%{_unitdir}+` or `+%{_userunitdir}+`. `+%{_unitdir}+` evaluates to `+/usr/lib/systemd/system+` on all Fedora systems and `+%{_userunitdir}%+` evaluates to `+/usr/lib/systemd/user+`. Unit files are architecture independent (hence, not `+%{_lib}+`) and needed early in the boot process. Most systemd service files should use `+%{_unitdir}+`. However, if the service runs as part of a user session (e.g. pipewire services, gpg-agent, tracker, etc), use `+%{_userunitdir}+` instead.
Please note that in order for the `+%{_unitdir}+` or `+%{_userunitdir}+` macro to exist, your package must have:
BuildRequires: systemd-rpm-macros
%files section
Systemd unit `+.service+` files must not be marked as `+%config+` files.
Unit files in spec file scriptlets
Information on proper handling of unit files in spec file scriptlets can be found here: xref:Scriptlets.adoc#_systemd[Scriptlets#Systemd].
Tmpfiles.d
tmpfiles.d is a service provided systemd for managing temporary files and directories for daemons. For more information on how to use Tmpfiles.d in Fedora Packages, please see: xref:Tmpfiles.d.adoc[Tmpfiles.d].
Why don't we....
Start the service after installation?
Installations can be in changeroots, in an installer context, or in other situations where you don't want the services autostarted.