when running a command that boots the image
- More directories aside from `/etc` and `/usr` are now picked up from
sandbox trees (formerly known as package manager trees).
+- Profile configuration from `mkosi.profiles` is now parsed after
+ `mkosi.conf.d` instead of before it. To set defaults for use in `mkosi.conf.d`
+ based on the configured profile, use an early dropin in `mkosi.conf.d` that
+ matches on the configured profile instead.
## v24
setattr(self.config, s.dest, s.parse(v, getattr(self.config, s.dest, None)))
self.parse_new_includes()
+ profilepath = None
if profiles:
profile = self.finalize_value(SETTINGS_LOOKUP_BY_DEST["profile"])
self.immutable.add("Profile")
if profile:
- for p in (profile, f"{profile}.conf"):
- p = Path("mkosi.profiles") / p
- if p.exists():
+ for p in (Path(profile), Path(f"{profile}.conf")):
+ profilepath = Path("mkosi.profiles") / p
+ if profilepath.exists():
break
else:
die(f"Profile '{profile}' not found in mkosi.profiles/")
setattr(self.config, "profile", profile)
- with chdir(p if p.is_dir() else Path.cwd()):
- self.parse_config_one(p if p.is_file() else Path("."))
-
if extras and (path.parent / "mkosi.conf.d").exists():
for p in sorted((path.parent / "mkosi.conf.d").iterdir()):
if p.is_dir() or p.suffix == ".conf":
with chdir(p if p.is_dir() else Path.cwd()):
self.parse_config_one(p if p.is_file() else Path("."))
+ if profilepath:
+ with chdir(profilepath if profilepath.is_dir() else Path.cwd()):
+ self.parse_config_one(profilepath if profilepath.is_file() else Path("."))
+
return True
* `mkosi.conf` is parsed if it exists in the directory configured with
`--directory=` or the current working directory if `--directory=` is
not used.
-* If a profile is defined, its configuration is parsed from the
- `mkosi.profiles/` directory.
* `mkosi.conf.d/` is parsed in the same directory 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.
+* 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.
Note that settings configured via the command line always override
: Select the given profile. A profile is a configuration file or
directory in the `mkosi.profiles/` directory. When selected, this
configuration file or directory is included after parsing the
- `mkosi.conf` file, but before any `mkosi.conf.d/*.conf` drop in
- configuration.
+ `mkosi.conf.d/*.conf` drop in configuration files.
`Dependencies=`, `--dependency=`
: The images that this image depends on specified as a comma-separated
_, [config] = parse_config()
assert config.profile == "profile"
- # mkosi.conf.d/ should override the profile
- assert config.distribution == Distribution.debian
+ # The profile should override mkosi.conf.d/
+ assert config.distribution == Distribution.fedora
assert config.qemu_kvm == ConfigFeature.enabled
(d / "mkosi.conf").unlink()
_, [config] = parse_config(["--profile", "profile"])
assert config.profile == "profile"
- # mkosi.conf.d/ should override the profile
- assert config.distribution == Distribution.debian
+ # The profile should override mkosi.conf.d/
+ assert config.distribution == Distribution.fedora
assert config.qemu_kvm == ConfigFeature.enabled