]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Add support for mkosi.initrd.conf to configure the default initrd
authorDaan De Meyer <daan@amutable.com>
Fri, 13 Feb 2026 15:55:08 +0000 (16:55 +0100)
committerDaan De Meyer <daan@amutable.com>
Fri, 13 Feb 2026 16:08:12 +0000 (17:08 +0100)
We have mkosi.tools.conf, we might as well add mkosi.initrd.conf as
well.

mkosi/config.py
mkosi/resources/man/mkosi.1.md

index 0de06c083aecac68c16df2870bb00fe04d19783c..3101cecbbdfd50fe28e1edf44860f97f3fd30aeb 100644 (file)
@@ -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(
index 405f17c0c03b30bb80002b7c84bd1f76f0377286..bf518811eaf4add600e5e32c4ebd4594a9c39668 100644 (file)
@@ -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.