Skip to content

[__systemd_unit] add --unique-drop-in - #163

Merged
4nd3r merged 1 commit into
mainfrom
4nd3r/__systemd_unit_dropin_name
Sep 14, 2026
Merged

4nd3r merged 1 commit into
mainfrom
4nd3r/__systemd_unit_dropin_name

Conversation

@4nd3r

@4nd3r 4nd3r commented Sep 10, 2026

Copy link
Copy Markdown
Member

From:
https://www.freedesktop.org/software/systemd/man/latest/systemd.unit.html

... equally named drop-in files further down the prefix hierarchy override those further up, i.e. foo-bar-.service.d/10-override.conf overrides foo-.service.d/10-override.conf.

It's a feature, but I consider this a bug. But oh well, fix is simple - use unique names.

This bites me when I have service template e.g. app@.service with drop-in and then also app@instance.service with drop-in too. When both drop-ins are called override.conf, then only last gets read.

This "fix" is somewhat ugly, I agree, but I couldn't think anything more saner and I don't want to deal with it manually e.g. introduce new parameter and then set it when needed.

@4nd3r 4nd3r assigned 4nd3r and sideeffect42 and unassigned 4nd3r Sep 10, 2026
@sideeffect42

Copy link
Copy Markdown
Member

Hmm, this is a tough one.
If it's supposedly a feature, I'm wondering if there would be a use case where systemd's behaviour is desirable?
If there is, maybe the user should specify the name of the drop-in so that they can control the behaviour?

However, this would be a breaking change, so 🤷.

Another thing which caught my eye is the use of md5sum. Can we assume that every system running systemd has it available?
Or would it be better to just use the unit file name or generate a slug of the service name instead of the hash? Would certainly be more predictable/readable.

@sideeffect42 sideeffect42 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't use systemd, so I don't really have an opinion.

@4nd3r
4nd3r force-pushed the 4nd3r/__systemd_unit_dropin_name branch from 6a7681b to e6ef28c Compare September 14, 2026 11:44
@4nd3r
4nd3r force-pushed the 4nd3r/__systemd_unit_dropin_name branch from e6ef28c to b732f15 Compare September 14, 2026 11:44
@4nd3r 4nd3r changed the title [__systemd_unit] use unique name for drop-in file [__systemd_unit] add --unique-drop-in Sep 14, 2026
@4nd3r

4nd3r commented Sep 14, 2026

Copy link
Copy Markdown
Member Author

Moved this to separate parameter. Makes more sense this way, also compatibility.

Also reminds me that this type is rather ugly and needs to be rewritten with all the known edge-cases. It's still in my TODO, but that will not happen today.

@4nd3r
4nd3r merged commit 4a90078 into main Sep 14, 2026
2 checks passed
@4nd3r
4nd3r deleted the 4nd3r/__systemd_unit_dropin_name branch September 14, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants