Closed realroot2185 closed 5 months ago
For reference Chimera Linux already does that: https://github.com/chimera-linux/turnstile/blob/00fd0b1ad7b5fd262bb83c75cb463ad32b1940c9/backend/dinit#L78-L88
As Mobin points out this is already possible, it just needs the dinit user instance to be started with the right command line to add the services directory (/etc/dinit.d/user
) as well the user's own (normally ~/.config/dinit.d
). That should be managed by whatever you have in place to launch the dinit user instances (eg Turnstile does this out of the box).
Anything I'm missing or can we close this?
I think that as dinit looks in /etc/dinit.d/service-name
and $XDG_CONFIG_HOME/dinit.d/service-name
it should look in /etc/dinit.d/user
out of the box.
And not relying on something else.
For example in sxmo I use dinit for user services and I just use dinit -u
.
As per the readme, we are not accepting feature requests except in certain circumstances, unless you are willing to work on it yourself. Is that the case?
In my opinion this is something that should be in dinit.
It thinks that it is not hard to add especially for dinit devs. Is that maybe a good circumstance?
I can try to look but I do not know.
In my opinion this is something that should be in dinit. It thinks that it is not hard to add especially for dinit devs. Is that maybe a good circumstance?
There are two Dinit developers, myself and Mobin, but we are both busy (with our lives outside Dinit, and with implementing high priority features/improvements). I agree this shouldn't be too hard to implement, it will still take time (it needs at least minimal testing, and documentation updates, as well) and there are other things to work on that are more important. That is why feature requests are in general only accepted when people are willing to work on it themselves.
For example in this case, I don't have any strong objection to the feature (if you want to implement it), but I also don't see it as important.
Here?
Yes - that's the function that builds up the service directory list.
Not sure to how implement priority.
For example if you have a service with the same name in /etc/dinit.d
and /lib/dinit.d
is there a priority ?
man dinit Dinit reads service descriptions from files located in a service description directory, normally one of /etc/dinit.d, /run/dinit.d, /usr/local/lib/dinit.d and /lib/dinit.d for the system instance...
Could it be done like this?
I added one line with //FIX HERE
.
void service_dir_opt::build_paths(bool am_system_init)
{
if (service_dirs.empty()) {
bool home_service_dir_set = false;
/* service directory name */
if (!am_system_init) {
service_dir_paths.emplace_back("/etc/dinit.d/user", /*dyn_allocd=*/false); //FIX HERE
const char * xdg_config_home = getenv("XDG_CONFIG_HOME");
size_t xdg_config_home_len;
man dinit
you need to read a little futher:
If not specified, the default is $HOME/.config/dinit.d or, for
the system service manager, each of /etc/dinit.d, /run/dinit.d/,
/usr/local/lib/dinit.d, and /lib/dinit.d (searched in that
order).
and
/etc/dinit.d, /run/dinit.d, /usr/local/lib/dinit.d, /lib/dinit.d
Default locations for service description files. The directories
are searched in the order listed.
They are search in order, i.e. it finds the service in the first one in the ordered list of directories.
Could it be done like this?
No, that would put it at the beginning of the search order instead of the end.
done_user_home:
service_dir_paths.emplace_back("/etc/dinit.d/user", /*dyn_allocd=*/false); //HERE
After done_user_home:
?
After done_user_home:?
that seems reasonable
Do I test it now to help?
Yes please, any contribution should be tested if at all possible. Normally actual unit tests or integration tests should be added, but that would probably be difficult for this change and it's ok to skip that this time. The process should basically be:
Please make sure code and documentation changes match existing style as much as possible. Thanks!
From man dinit-service:
A system-wide location for user services could be very useful.
For example when installing some DE with user services a package could install them in
/etc/dinit.d/user/
folder so that it will work out of the box. Or if you install just some service e.g. the Artix packagegalaxy/pipewire-dinit 20230930-2
.Then users can make their version in
$XDG_CONFIG_HOME/dinit.d/
to override system one.To avoid problems all user services file would go there. E.g. scripts folder would be:
/etc/dinit.d/user/scripts
.