mkosi icon indicating copy to clipboard operation
mkosi copied to clipboard

Extend support for distribution specific configuration files

Open johannbg opened this issue 4 years ago • 4 comments

This basically is a request of supporting opposite of shared configuration between distribution.

The idea is when you run "sudo mkosi -d $distribution" from the command line, mkosi should first check if there already exists a distribution specific configuration file.

The search path should be.

.mkosi/mkosi.$distribution
mkosi/mkosi.$distribution
mkosi.$distribution

Nothing found, use the built in defaults for distribution.

This above is better approach than having to later on symbolic link a "default" to a specific distribution.

Following the above structure mkosi should support searching for a specific mkosi directory hierarchy within those distributions as in

The search path should be.

.mkosi/mkosi.$distribution.d
mkosi/mkosi.$distribution.d
mkosi.$distribution.d

Which could contain mkosi.cache,mkosi.extra, mkosi.files, mkosi.output etc. putting it together the directory tree + search would look like this...

.mkosi/mkosi.$distribution.d/
                             mkosi.cache
                             mkosi.extra
                             mkosi.files
                             mkosi.output 
                             etc...

mkosi/mkosi.$distribution.d/ 
                            mkosi.cache
                            mkosi.extra
                            mkosi.files
                            mkosi.output 
                            etc...

mkosi.$distribution.d/
                      mkosi.cache
                      mkosi.extra
                      mkosi.files
                      mkosi.output 
                      etc...

This above approach could also support mkosi.shared.d and mkosi.default.d directory.

One of the thing that I have had a problem wrapping my head around is why you suddenly decided to abandon the mkosi.$foo approach and chose .conf configuration for the defaults instead ( as opposed to mkosi.shared and or mkosi.default ) unless ofcourse the plan is to abandon mkosi.$foo files in the future.

johannbg avatar Feb 10 '21 08:02 johannbg

We do already parse distribution specific configs in mkosi.default.d/$distro so you can use that and simply manually specify paths to the other files to make this work. Ideally this would work out of the box but unfortunately, mkosi never enforced a file extension for its config files so to keep backwards compat, we have to treat every file in the directory as a config file.

I don't mind breaking backwards compat here. There's definitely ways we can make this work without breaking existing use cases too much. Would happily review a PR for this.

DaanDeMeyer avatar Feb 18 '21 21:02 DaanDeMeyer

Have you not already broken compat I mean .mkosi and or mkosi is the original directory hierarchy for mkosi so why would you suddenly decided to parse the distribution files from mkosi.default.d instead? What purpose is .mkosi and or mkosi directory supposed to serve then?

johannbg avatar Feb 18 '21 22:02 johannbg

I don't think we have anything in the docs or code that says .mkosi or mkosi is the original hierarchy? The systemd repo uses .mkosi/ to store mkosi files but there's nothing specific to that directory in the codebase. Unlike mkosi.default.d which is encoded in the mkosi script and docs as the directory for drop-in files so we extended that directory to allow for distro specific dropins as well.

DaanDeMeyer avatar Feb 18 '21 22:02 DaanDeMeyer

Hmm I thought the original search path, searched there by default, I need to look at the code and see if and then when that has been changed or I'm just imagining it.

Could have been Lennart's original blog post that mentioned this anyway if the intent is to use mkosi.default.d then the mkosi default search path needs to be configurable/overwritten and or at least search as a fallback within .mkosi/ and mkosi/ directory's if no mkosi.default and or mkosi.default.d is found because people want to minimize files in the top-level directory of the git tree as in contain everything within .mkosi and or mkosi directory hierarchy thus having mkosi.default and mkosi.default.d is redundant with the expectation of simply contain everything within . and .mkosi/ and mkosi/ directory hierarchy.

johannbg avatar Feb 18 '21 23:02 johannbg

You can now put directories in mkosi.conf.d/ and mkosi will treat them like regular top level directories and parse all config and defined paths in them. We also have support for [Match] sections now and a config file (and for mkosi.conf, the directory it's in) will only be parsed if all conditions in the [Match] section are satisfied, so this can be considered fixed now.

DaanDeMeyer avatar Apr 11 '23 18:04 DaanDeMeyer