mkosi icon indicating copy to clipboard operation
mkosi copied to clipboard

`mkosi summary`-esque helper function

Open Winterhuman opened this issue 2 years ago • 1 comments

mkosi: v19

Description

Parsing /work/src/mkosi.conf within a chrooted script is relatively simple to do, however, when mkosi.conf.d/*.conf or mkosi.images are involved things could become much more complicated. Ideally, there would be a way to run mkosi summary from within chrooted scripts to get an overview of the overall effective config.

What I'm proposing is a mkosi summary-esque helper function which prints the full list of config options in an easy-to-parse format. As an example to demonstrate:

$ mkosi-summary-helper
Locale=en_GB.UTF-8
Distribution=arch
CompressOutput=zst
Packages=bash less linux sudo systemd
...

$ mkosi-summary-helper | grep "Locale" | ...

This helper function would use the same config parsing logic as mkosi itself, accounting for mkosi.conf.d, mkosi.images, etc, which would eliminate the complexity of reimplementing the parsing logic.

Winterhuman avatar Dec 19 '23 21:12 Winterhuman

As discussed in matrix, we could probably just expose the JSON config for the current image as $MKOSI_CONFIG

DaanDeMeyer avatar Dec 20 '23 09:12 DaanDeMeyer

$MKOSI_CONFIG is now set to a path containing the mkosi config serialized as JSON. See #2473

DaanDeMeyer avatar Mar 14 '24 08:03 DaanDeMeyer