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 the
+ 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
`--directory=` or the current working directory if `--directory=` is
not used.
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.
-* Any default paths (depending on the option) are configured if the
- corresponding path exists.
Note that if the same setting is configured twice, the later assignment
overrides the earlier assignment unless the setting is a list based
that matching against a setting and then changing its value afterwards
in a different config file may lead to unexpected results.
+The `[Match]` section of a `mkosi.conf` file in a directory applies to
+the entire directory. If the conditions are not satisfied, the entire
+directory is skipped. The `[Match]` sections of files in `mkosi.conf.d/`
+and `mkosi.local.conf` only apply to the file itself.
+
Command line options that take no argument are shown without `=` in
their long version. In the config files, they should be specified with a
boolean argument: either `1`, `yes`, or `true` to enable, or `0`, `no`,
assert config.tools_tree is None
+def test_local_config(tmp_path: Path) -> None:
+ d = tmp_path
+
+ (d / "mkosi.local.conf").write_text(
+ """\
+ [Distribution]
+ Distribution=debian
+ """
+ )
+
+ with chdir(d):
+ _, [config] = parse_config()
+
+ assert config.distribution == Distribution.debian
+
+ (d / "mkosi.conf").write_text(
+ """\
+ [Distribution]
+ Distribution=fedora
+ """
+ )
+
+ with chdir(d):
+ _, [config] = parse_config()
+
+ assert config.distribution == Distribution.fedora
+
+
def test_parse_load_verb(tmp_path: Path) -> None:
with chdir(tmp_path):
assert parse_config(["build"])[0].verb == Verb.build