Hacker News new | ask | show | jobs
by LoganDark 1045 days ago
The file's pretty cumbersome, honestly, since I usually don't remember the format or the best practices for it.

Plus, sometimes there is no place to put them that isn't conflicting with the package manager, so "best practice" ends up being to make your own package containing the unit file, and ...

I'm not a big fan of "best practices" in general, but it'll turn into a whole rabbithole if you let it. At least with a piece of software like this, you just run a few commands and it remembers, and you get tons of sane defaults.

2 comments

This was solved from beginning of systemd with different directories for files mananged by package managers (under /lib), and files managed by you (under /etc). This is documented in `man systemd.unit`:

https://www.freedesktop.org/software/systemd/man/systemd.uni...

The same doc also describes a "drop-in" file format, where you can override just the details you want from a system file.

FWIW, you can override unit files that are installed by a package manager: https://hsm.tunnel53.net/article/systemd/
I think the "issue" isn't the package manager overwriting your custom unit files, but rather just the litter of untracked files in places the package manager is supposed to be in charge of. Since some people want to be able to track those files, and prevent them from making a mess.

In practice I don't think it is a huge issue. I've just left unit files laying around on embedded devices without issue. Hard to find which ones are mine though, if I've lost my mental list of them.

(Also, writing one from scratch without a template is annoying, since I haven't memorized the format.)

You can even do this with 'systemctl edit <unit>' and it'll create a file in the right place for the override and show you the original contents for reference