]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Read config from mkosi.local/ as well if it exists
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 21 Sep 2024 10:13:19 +0000 (12:13 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Sat, 21 Sep 2024 19:08:03 +0000 (21:08 +0200)
.gitignore
mkosi/config.py
mkosi/resources/man/mkosi.md

index 4d1b379d3e0a0bd07299da248e521565d6c4fb08..6d489f55e15a5c5d213be75c84badabcd12f5dc8 100644 (file)
@@ -20,6 +20,7 @@
 /mkosi.output
 /mkosi.nspawn
 /mkosi.rootpw
+mkosi.local
 mkosi.local.conf
 /mkosi.key
 /mkosi.crt
index 2c8ecb92831816c9c307db80898815c36573620a..34c1e0de8f520e9a7a5351be61e990734f60ce49 100644 (file)
@@ -3782,21 +3782,26 @@ class ParseContext:
         extras = path.is_dir()
 
         if path.is_dir():
-            path = path / "mkosi.conf"
+            path /= "mkosi.conf"
 
         if not self.match_config(path):
             return False
 
         if extras:
-            if local and (path.parent / "mkosi.local.conf").exists():
-                self.parse_config_one(path.parent / "mkosi.local.conf")
-
-                # Configuration from mkosi.local.conf should override other file based configuration but not
-                # the CLI itself so move the finalized values to the CLI namespace.
-                for s in SETTINGS:
-                    if hasattr(self.config, s.dest):
-                        setattr(self.cli, s.dest, self.finalize_value(s))
-                        delattr(self.config, s.dest)
+            if local:
+                if (
+                    (localpath := path.parent / "mkosi.local/mkosi.conf").exists()
+                    or (localpath := path.parent / "mkosi.local.conf").exists()
+                ):  # fmt: skip
+                    self.parse_config_one(localpath)
+
+                    # Local configuration should override other file based
+                    # configuration but not the CLI itself so move the finalized
+                    # values to the CLI namespace.
+                    for s in SETTINGS:
+                        if hasattr(self.config, s.dest):
+                            setattr(self.cli, s.dest, self.finalize_value(s))
+                            delattr(self.config, s.dest)
 
             for s in SETTINGS:
                 if (
index a04783688835c12af986dacfa2f3920b53a8c24e..1602fae77133f79f6222d2c7c31e75461824312f 100644 (file)
@@ -299,8 +299,9 @@ grouped by section below.
 Configuration is parsed in the following order:
 
 * The command line arguments are parsed.
-* `mkosi.local.conf` is parsed if it exists. This file should be in
-  `.gitignore` (or equivalent) and is intended for local configuration.
+* `mkosi.local.conf` or `mkosi.local` is parsed if it exists. This file or
+  directory should be in `.gitignore` (or equivalent) and is intended for local
+  configuration.
 * Any default paths (depending on the option) are configured if the
   corresponding path exists.
 * `mkosi.conf` is parsed if it exists in the directory configured with
@@ -318,9 +319,9 @@ Note that settings configured via the command line always override
 settings configured via configuration files. If the same setting is
 configured more than once via configuration files, later assignments
 override earlier assignments except for settings that take a collection
-of values. Also, settings read from `mkosi.local.conf` will override
-settings from configuration files that are parsed later, but not settings
-specified on the CLI.
+of values. Also, settings read from `mkosi.local` or `mkosi.local.conf` will
+override settings from configuration files that are parsed later, but not
+settings specified on the CLI.
 
 For settings that take a single value, the empty assignment (`SomeSetting=` or
 `--some-setting=`) can be used to override a previous setting and reset to the