From: Daan De Meyer Date: Fri, 13 Feb 2026 15:55:08 +0000 (+0100) Subject: Add support for mkosi.initrd.conf to configure the default initrd X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=677c3b8546e07076b435f25ff06a92f007f3f39a;p=thirdparty%2Fmkosi.git Add support for mkosi.initrd.conf to configure the default initrd We have mkosi.tools.conf, we might as well add mkosi.initrd.conf as well. --- diff --git a/mkosi/config.py b/mkosi/config.py index 0de06c083..3101cecbb 100644 --- a/mkosi/config.py +++ b/mkosi/config.py @@ -5197,6 +5197,7 @@ def finalize_default_initrd( main: ParseContext, finalized: dict[str, Any], *, + configdir: Path | None, resources: Path, ) -> Config: context = ParseContext(resources) @@ -5233,6 +5234,10 @@ def finalize_default_initrd( for name in finalized.get("environment", {}).keys() & finalized.get("pass_environment", []) } + if configdir and (p := configdir / "mkosi.initrd.conf").exists(): + with chdir(p if p.is_dir() else Path.cwd()): + context.parse_config_one(p, parse_profiles=p.is_dir(), parse_local=p.is_dir()) + with chdir(resources / "mkosi-initrd"): context.parse_config_one(resources / "mkosi-initrd", parse_profiles=True) @@ -5500,7 +5505,7 @@ def parse_config( subimages = [Config.from_dict(ns) for ns in images] if any(want_default_initrd(image) for image in subimages + [main]): - initrd = finalize_default_initrd(maincontext, config, resources=resources) + initrd = finalize_default_initrd(maincontext, config, configdir=configdir, resources=resources) if want_default_initrd(main): main = dataclasses.replace( diff --git a/mkosi/resources/man/mkosi.1.md b/mkosi/resources/man/mkosi.1.md index 405f17c0c..bf518811e 100644 --- a/mkosi/resources/man/mkosi.1.md +++ b/mkosi/resources/man/mkosi.1.md @@ -377,9 +377,9 @@ Configuration is parsed in the following order: * `mkosi.conf.d/` is parsed in the same directory as `mkosi.conf` if it exists. Each directory and each file with the `.conf` extension in `mkosi.conf.d/` is parsed. Any directory in `mkosi.conf.d` is parsed - as if it were a regular top level directory, except for `mkosi.images/` - and `mkosi.tools.conf`, which are only picked up in the top level - directory. + as if it were a regular top level directory, except for `mkosi.images/`, + `mkosi.tools.conf` and `mkosi.initrd.conf`, which are only picked up in + the top level directory. * If any profiles are configured, their configuration is parsed from the `mkosi.profiles/` directory. * Subimages are parsed from the `mkosi.images/` directory if it exists. @@ -1129,6 +1129,10 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, specifying this setting, the special value `default` can be assigned alongside the other values. + When the default initrd is used, it can be further configured using the settings below and + with `mkosi.initrd.conf` which can either be a file or directory containing extra configuration + for the default initrd. + **mkosi** will also look for initrds in a subdirectory `io.mkosi.initrd` of the artifact directory (see `$ARTIFACTDIR` in the section **ENVIRONMENT VARIABLES**). Any initrds found there are appended to the user-provided @@ -1474,7 +1478,7 @@ boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`, If set to `yes`, **mkosi** will automatically add an extra tools tree image and use it as the tools tree. This image can be further configured - using the settings below or with `mkosi.tools.conf` which can either be a + using the settings below and with `mkosi.tools.conf` which can either be a file or directory containing extra configuration for the default tools tree. See the **TOOLS TREE** section for further details.