]> git.ipfire.org Git - thirdparty/mkosi.git/log
thirdparty/mkosi.git
9 hours agoRevert "Add Incremental=relaxed" main
Daan De Meyer [Thu, 9 Apr 2026 09:52:24 +0000 (11:52 +0200)] 
Revert "Add Incremental=relaxed"

This does not work as a per distribution CacheKey= means that
we can switch between distributions without invalidating caches,
meaning the output files won't be removed yet will still be those
of the previous distribution rather than the new one.

Revert for now until I figure out a better approach.

This reverts commit a97c50044ce19d72e5119cd11af6993c3944ab65.

13 hours agoAvoid invalidating all caches on mid-build-failure recovery
Daan De Meyer [Thu, 9 Apr 2026 08:28:43 +0000 (08:28 +0000)] 
Avoid invalidating all caches on mid-build-failure recovery

Previously, repository_metadata_needs_sync() returned True whenever any
Cacheonly=auto image lacked a cache, which caused run_clean() to wipe
every image cache to avoid partial-upgrade scenarios. As a result, if
mkosi was building several images for the first time and one of them
failed mid-way, the next run would re-sync metadata, wipe the caches of
the images that had already succeeded, and rebuild everything from
scratch.

Use the manifest file as a "previously cached" marker — it's written
when an image builds successfully and survives even after the cache
contents go stale — and only re-sync metadata (and invalidate all
caches) when every incremental image was previously cached and at least
one of them is now out of date. In the mid-build-failure case, the image
that failed never wrote a manifest, so we don't trigger the re-sync and
the surviving caches are preserved.

For all-non-incremental setups we keep the previous behavior of always
syncing — there are no caches to preserve and every build downloads
packages. In a mixed setup, the non-incremental images are ignored by
the heuristic and may eventually fail because of stale metadata, but
that's the cost of mixing them with incremental images we want to
preserve.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
6 days agonspawn: Drop logic to run systemd-repart on the image before booting
Daan De Meyer [Fri, 3 Apr 2026 06:54:40 +0000 (08:54 +0200)] 
nspawn: Drop logic to run systemd-repart on the image before booting

This bit still requires root and it's unlikely we'll ever be able to
make it work unprivileged. Instead we should probably do something with
mstack in the future instead. But for now let's drop this logic so that
booting (verity signed) disk images works unprivileged on systems with
nsresourced and mountfsd.

6 days agovmspawn: Make sure we clean up auxiliary files as well
Daan De Meyer [Thu, 2 Apr 2026 21:16:20 +0000 (23:16 +0200)] 
vmspawn: Make sure we clean up auxiliary files as well

6 days agovmspawn: Set fewer credentials
Daan De Meyer [Sat, 28 Mar 2026 15:05:37 +0000 (16:05 +0100)] 
vmspawn: Set fewer credentials

This also fixes the accidentally commented out console=hvc0 in a
previous commit.

6 days agomkosi-tools: use correct pkg name for codespell on postmarketOS
Clayton Craft [Fri, 3 Apr 2026 00:11:44 +0000 (17:11 -0700)] 
mkosi-tools: use correct pkg name for codespell on postmarketOS

Fixes 31852c9314190b10376a009a380ffa527a57fae8

6 days agoFall back from nsresourced on UserNamespaceInterfaceNotSupported
Clayton Craft [Fri, 3 Apr 2026 01:21:26 +0000 (18:21 -0700)] 
Fall back from nsresourced on UserNamespaceInterfaceNotSupported

This fixes an issue with running mkosi on postmarketOS, where mkosi
was failing if nsresourced was unable to initialize BPF support. The
error is treated the same as InvalidParameter so mkosi falls back to an
unprivileged user namespace when the kernel lacks BPF LSM support.

Work to enable BPF LSM support there is ongoing[1].

1. https://gitlab.postmarketos.org/postmarketOS/pmaports/-/work_items/4411

7 days agoBuild UKI when making directory images with Bootable=auto
Daan De Meyer [Thu, 2 Apr 2026 11:29:27 +0000 (13:29 +0200)] 
Build UKI when making directory images with Bootable=auto

qemu supports direct kernel booting UKI images with virtiofs as the
rootfs so let's make that work by building UKIs if we're building
directory images with Bootable=auto. Importantly, we build a UKI
without an initrd in that case so that the time consuming step of
building the initrd is still skipped.

7 days agovmspawn: Support --console=headless
Daan De Meyer [Thu, 2 Apr 2026 11:45:35 +0000 (13:45 +0200)] 
vmspawn: Support --console=headless

vmspawn has support for --console=headless now.

7 days agovmspawn: Support booting UKIs and directory images with UKIs
Daan De Meyer [Thu, 2 Apr 2026 11:44:36 +0000 (13:44 +0200)] 
vmspawn: Support booting UKIs and directory images with UKIs

7 days agovmspawn: Support DiskType
Daan De Meyer [Thu, 2 Apr 2026 11:47:40 +0000 (13:47 +0200)] 
vmspawn: Support DiskType

7 days agoqemu: Support scsi-cd disk type
Daan De Meyer [Thu, 2 Apr 2026 11:47:21 +0000 (13:47 +0200)] 
qemu: Support scsi-cd disk type

For testing the el torito stuff.

7 days agoci: Update claude-review with latest changes from systemd
Daan De Meyer [Thu, 2 Apr 2026 06:57:10 +0000 (08:57 +0200)] 
ci: Update claude-review with latest changes from systemd

7 days agoAdd support for repart's new ElTorito settings
Daan De Meyer [Thu, 2 Apr 2026 08:22:16 +0000 (10:22 +0200)] 
Add support for repart's new ElTorito settings

7 days agoci: fix mypy failing because pytest 9 does not support python 3.9
Jörg Behrmann [Thu, 2 Apr 2026 08:34:26 +0000 (10:34 +0200)] 
ci: fix mypy failing because pytest 9 does not support python 3.9

7 days agomkosi-initrd: Add sr_mod to default kernel modules
Daan De Meyer [Thu, 2 Apr 2026 08:27:41 +0000 (10:27 +0200)] 
mkosi-initrd: Add sr_mod to default kernel modules

Required for cd devices like qemu's scsi-cd.

11 days agoAdd DriveType= setting for qemu root disk device type
Christian Brauner [Sat, 21 Mar 2026 12:54:27 +0000 (13:54 +0100)] 
Add DriveType= setting for qemu root disk device type

Add a new DriveType= setting that allows configuring the device type
used for the root disk when booting a virtual machine with qemu. The
supported types are virtio-blk (default, preserving existing behavior),
virtio-scsi, and nvme.

Previously, the only way to use nvme was by manually adding qemu device
arguments via QemuArgs=. This makes nvme a first-class option.

When Removable= is enabled, the drive type is forced to virtio-scsi
regardless of the DriveType= setting, preserving existing behavior.

Signed-off-by: Christian Brauner <brauner@kernel.org>
12 days agodetect_distribution: Fall back to default_release() when VERSION_ID is unset
Daan De Meyer [Sat, 28 Mar 2026 15:10:51 +0000 (15:10 +0000)] 
detect_distribution: Fall back to default_release() when VERSION_ID is unset

Some distributions like Arch Linux don't set VERSION_ID in their
os-release file (they use BUILD_ID=rolling instead). This caused
detect_distribution() to return None for the release, which had two
consequences:

1. The MKOSI_HOST_RELEASE environment variable was never propagated
   into sandbox/box environments (since the truthy check at the
   sandbox setup skipped it), losing host release information.

2. The cache key specifier &r expanded to an empty string, producing
   cache paths like arch~~x86-64~main.cache instead of the expected
   arch~rolling~x86-64~main.cache.

Fix this by falling back to the distribution's default_release() in
detect_distribution() when VERSION_ID is not available. This also
allows simplifying the hr is not None guard in config_default_release()
to a simple truthy check, since detect_distribution() now always
returns a release for known distributions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
12 days agovmspawn: Add support for FirmwareVariables=
Daan De Meyer [Fri, 27 Mar 2026 13:57:28 +0000 (14:57 +0100)] 
vmspawn: Add support for FirmwareVariables=

Use vmspawn's new --firmware=describe to query the selected firmware
description as JSON, and extract the NVRAM template path from it. This
avoids duplicating vmspawn's firmware selection logic in mkosi.

The NVRAM template is then prepared via finalize_firmware_variables()
(handling custom cert enrollment, MOK enrollment, or plain copy) and
passed to vmspawn via --efi-nvram-template.

We also pass --firmware-features to vmspawn so it selects the right
firmware description (e.g. secure-boot, enrolled-keys).

As part of this, finalize_firmware_variables() is refactored to accept
the vars template Path directly instead of the full OvmfConfig, with
the vars format logic moved to the run_qemu() caller since vmspawn
does not need it.

2 weeks agoAllow multiarch in mkosi.sources
Andre Wagner [Wed, 25 Mar 2026 10:47:29 +0000 (11:47 +0100)] 
Allow multiarch in mkosi.sources

If the mkosi.sources contains other package sources for other
architectures (e.g. armhf or arm64 from ports.ubuntu.com)
than the architecture it is build for (e.g. amd64), then
apt will fail because of package conflicts of the form:

package_name conflicts package_name:armhf conflicts package_name:arm64

Even if the versions meantioned there are exactly the same
and apt is run with:

APT::Architecture="<debbuildarch>" and APT:Architectures="<debbuildarch>"

So adding ?architecture(<debbuildarch>) really forces
<buildarch> on all packages, the packages for other architectures
are not considered anymore and building succeeds.

The underlying problem seems to be that ?essential apt-pattern
(and perhaps all other apt-patterns) do not filter with
APT::Architecture(s)

2 weeks agoAGENTS.md: Drop mkosi box from build and test commands
Daan De Meyer [Thu, 26 Mar 2026 17:23:17 +0000 (18:23 +0100)] 
AGENTS.md: Drop mkosi box from build and test commands

It's easier to run the agent inside mkosi box.

2 weeks agovmspawn: Escape qemu arguments passed to vmspawn
Daan De Meyer [Thu, 26 Mar 2026 13:12:58 +0000 (14:12 +0100)] 
vmspawn: Escape qemu arguments passed to vmspawn

2 weeks agoAdd /usr/local/bin to PATH
Jörg Behrmann [Thu, 26 Mar 2026 08:31:53 +0000 (09:31 +0100)] 
Add /usr/local/bin to PATH

While things installed in images can be controlled by the image creator and
should go to /usr/bin, they can't always control where tools install things and
so adding /usr/local/bin to PATH is an often needed workaround.

Let's add it and be done with it.

Fixes: #4240
2 weeks agovmspawn: Pass in regular command line options as well
Daan De Meyer [Thu, 26 Mar 2026 09:34:22 +0000 (10:34 +0100)] 
vmspawn: Pass in regular command line options as well

Same as we do in qemu.

2 weeks agoAdd gh to devel profile mkosi's default tools tree
Daan De Meyer [Wed, 25 Mar 2026 21:30:30 +0000 (22:30 +0100)] 
Add gh to devel profile mkosi's default tools tree

2 weeks agovmspawn: Implement registration
Daan De Meyer [Tue, 24 Mar 2026 22:06:13 +0000 (23:06 +0100)] 
vmspawn: Implement registration

2 weeks agoRevert "run: print what is executed at info level"
Daan De Meyer [Tue, 24 Mar 2026 09:46:26 +0000 (10:46 +0100)] 
Revert "run: print what is executed at info level"

This is too noisy, e.g. when running mkosi box there should
be no output, and now it shows a bunch of commands being
executed every time.

This reverts commit 8b1bbe29374f0322c9e36fc1beeb061fad3d5259.

2 weeks agoAllow booting directory images owned by root if running as root
Daan De Meyer [Mon, 23 Mar 2026 19:43:29 +0000 (20:43 +0100)] 
Allow booting directory images owned by root if running as root

Alternative to #4214. While we still don't support booting images
built as non-root uids without the foreign UID range, we can make
an exception for images built and booted as root.

2 weeks agoqemu: Drop support for booting with BIOS firmware
Daan De Meyer [Mon, 23 Mar 2026 19:58:41 +0000 (20:58 +0100)] 
qemu: Drop support for booting with BIOS firmware

We want to drop support for mkosi qemu sooner rather than later and
rely on systemd-vmspawn. Since we won't add BIOS firmware support
to systemd-vmspawn, let's drop support for booting with BIOS firmware.

2 weeks agovmspawn: Support extra drives
Daan De Meyer [Mon, 23 Mar 2026 20:31:17 +0000 (21:31 +0100)] 
vmspawn: Support extra drives

2 weeks agoci: Drop codeql
Daan De Meyer [Mon, 23 Mar 2026 19:21:30 +0000 (20:21 +0100)] 
ci: Drop codeql

This has been doing nothing except produce false positives, let's
get rid of it.

2 weeks agomkosi-initrd: add --show-summary/-S
Zbigniew Jędrzejewski-Szmek [Sat, 21 Mar 2026 12:03:21 +0000 (13:03 +0100)] 
mkosi-initrd: add --show-summary/-S

This is quite useful to figure out what configuration is used.

(I considered adding an option to allow arbitrary mkosi verbs.
But most verbs either don't make sense or don't work. E.g. 'shell'
could be potentially useful but it doesn't support cpio atm. So
limiting this to 'summary' for now seems OK. Having an easy way
to show the config will be useful even if we add a more generic
hookup into mkosi later.)

2 weeks agoman: mention --show-documentation/-D
Zbigniew Jędrzejewski-Szmek [Sat, 21 Mar 2026 12:02:23 +0000 (13:02 +0100)] 
man: mention --show-documentation/-D

Follow-up for 26718491259db2ccad165d588a35848c5ea5dda4.

2 weeks agoman: mention where mkosi-initrd files live
Zbigniew Jędrzejewski-Szmek [Sat, 21 Mar 2026 11:51:28 +0000 (12:51 +0100)] 
man: mention where mkosi-initrd files live

2 weeks agoconfig: change comma|newline separators to comma|whitespace
Zbigniew Jędrzejewski-Szmek [Sat, 21 Mar 2026 11:05:59 +0000 (12:05 +0100)] 
config: change comma|newline separators to comma|whitespace

Configuration like 'FirmwareFiles=intel/ibt-0093-* intel/ipu/*' would be
interpreted as a single word. This is surprising and not useful. In
practice, none of the names that we use should ever have a space in
them. Change the parsing for host names, profile names, artifact output
lists, includes, dependency names, scripts, repository names, manifest
formats, repart directories, packages, package directories, trees, files
to remove, uki profiles, initrds, device trees, module and firmware
include/exclude lists to accept any-whitespace|comma instead of just
newline|comma as separators.

(The parsers that used space|newline as separators are not touched.)

Arguably, this is a compat break. But I think it's unlikely to matter in
any practical case and the removal of the surprising behaviour is more
important. The case where a space would be most likely to be used is
RemoveFiles… Fortunately that setting takes a glob so the user can just
"escape" the path with space as '?' or something to make it work.

2 weeks agoMake module-gathering functions return sets
Zbigniew Jędrzejewski-Szmek [Sat, 21 Mar 2026 09:07:02 +0000 (10:07 +0100)] 
Make module-gathering functions return sets

This makes the callers a bit simpler because then they don't need
to do explicit conversions of the returned object.

There are a few callers which previously turned the value into a
set, and one other caller which passed the value to make_cpio,
which turns it into a list with sorted(files). So the change should
be a noop.

2 weeks agorun: print what is executed at info level
Zbigniew Jędrzejewski-Szmek [Tue, 4 Nov 2025 09:23:27 +0000 (10:23 +0100)] 
run: print what is executed at info level

The tools that mkosi invokes are often quite verbose. So let's also
print what those executed commands are by default. This makes it
easier to figure out what is going on and doesn't change the total
number of printed lines too much.

2 weeks agoFail if we can't acquire a userns with foreign UID range if requested
Daan De Meyer [Thu, 19 Mar 2026 13:45:09 +0000 (14:45 +0100)] 
Fail if we can't acquire a userns with foreign UID range if requested

If the foreign UID range is requested, we need to fail if we can't
get a userns with it mapped in.

3 weeks agoHandle absence of /home gracefully
Kai Lüke [Tue, 17 Mar 2026 14:51:45 +0000 (23:51 +0900)] 
Handle absence of /home gracefully

When running mkosi nested in a systemd unit where /home exists but is
empty as a special build user is used, then the inner mkosi fails to
bind mount /home for some reason. Since this won't be interesting to
bind mount anyway, skip the bind mount.

3 weeks agoci: Update claude-review with latest changes from systemd
Daan De Meyer [Thu, 19 Mar 2026 11:26:50 +0000 (12:26 +0100)] 
ci: Update claude-review with latest changes from systemd

3 weeks agomanifest: use `dataclasses.asdict` in PackageManifest
Michael Vogt [Tue, 17 Mar 2026 11:11:48 +0000 (12:11 +0100)] 
manifest: use `dataclasses.asdict` in PackageManifest

PackageManifest is already a dataclass and now we include
all fields so we can just use `dataclasses.asdict()` to convert
PackageManifest to a dict instead of doing it manually.

3 weeks agomanifest: include size in PackageManifest
Michael Vogt [Thu, 12 Mar 2026 16:10:27 +0000 (17:10 +0100)] 
manifest: include size in PackageManifest

For many use-cases the package size is interesting information,
e.g. when trying to build small images. Its also not that much
extra data so this commit adds it to the default manifest.

3 weeks agoLog nsresourced connection failures at warning when using ForeignUidRange=
Jörg Behrmann [Mon, 16 Mar 2026 09:45:09 +0000 (10:45 +0100)] 
Log nsresourced connection failures at warning when using ForeignUidRange=

3 weeks agoMerge pull request #4199 from pothos/logprefix
Daan De Meyer [Mon, 16 Mar 2026 12:51:03 +0000 (13:51 +0100)] 
Merge pull request #4199 from pothos/logprefix

Improve log output

3 weeks agoAllow printing of step durations with CLI flag 4199/head
Kai Lüke [Mon, 2 Mar 2026 02:39:24 +0000 (11:39 +0900)] 
Allow printing of step durations with CLI flag

The printing of the duration for each step was behind the --debug flag
which adds more noise when one is just interested in the build times.
Also, the printing of the step duration serves as good marker during
log reading to understand where the above log output belongs to.
Add a new --debug-timing flag to always print the step durations.

3 weeks agoAdd context to log output
Kai Lüke [Mon, 2 Mar 2026 02:17:53 +0000 (11:17 +0900)] 
Add context to log output

Currently it's not really easy to know which log output belongs to which
mkosi image when there's the tools tree image, the main image, and any
sub images.
Add a log prefix that remembers the current image so that it's not just
"‣  Installing Fedora Linux" but  "‣ [tools]  Installing Fedora Linux",
"‣ [default-initrd]  Installing Fedora Linux", and
"‣ [main]  Installing Fedora Linux".

3 weeks agoAdd local_mirror to cache manifest and tools tree (#4217)
Daan De Meyer [Mon, 16 Mar 2026 09:44:17 +0000 (10:44 +0100)] 
Add local_mirror to cache manifest and tools tree (#4217)

* Add local_mirror to cache manifest

Similar to how snapshot is part of the cache manifest we should rebuilt
an image if the local mirror changes.

* Allow LocalMirror= to be set for the tools tree

So far the LocalMirror= setting was rejected for the tools tree.

3 weeks agoci: Update claude-review with latest changes from systemd
Daan De Meyer [Mon, 16 Mar 2026 09:18:26 +0000 (10:18 +0100)] 
ci: Update claude-review with latest changes from systemd

3 weeks agoExplicitly fail on socket connection if connection is denied
Tulip Blossom [Mon, 16 Mar 2026 08:43:50 +0000 (05:43 -0300)] 
Explicitly fail on socket connection if connection is denied

When the user does have `systemd-nsresourced`, but the socket is unavailable for any reason (i.e. when the service is disabled/stopped), mkosi gets a `Connection refused` error and hangs instead of getting a varlink error.

3 weeks agoAllow LocalMirror= to be set for the tools tree 4217/head
Kai Lüke [Fri, 13 Mar 2026 15:27:09 +0000 (00:27 +0900)] 
Allow LocalMirror= to be set for the tools tree

So far the LocalMirror= setting was rejected for the tools tree.

4 weeks agoAdd local_mirror to cache manifest
Kai Lüke [Thu, 12 Mar 2026 13:25:51 +0000 (22:25 +0900)] 
Add local_mirror to cache manifest

Similar to how snapshot is part of the cache manifest we should rebuilt
an image if the local mirror changes.

4 weeks agomkosi: enable vtpm in the initrd
Lennart Poettering [Tue, 10 Mar 2026 21:23:45 +0000 (22:23 +0100)] 
mkosi: enable vtpm in the initrd

For the swtpm work in systemd it's kinda handy being able to spawn an
swtpm during initrd as a fallback solution for tpm-less systems. To do
this we need the vtpm kernel module. Add it.

4 weeks agoRevert "debian: use new tpm2-tss metapackage instead of library packages"
Luca Boccassi [Wed, 11 Mar 2026 01:00:36 +0000 (01:00 +0000)] 
Revert "debian: use new tpm2-tss metapackage instead of library packages"

This actually makes life harder when building UKIs for multiple
distros on the same OBS project, so revert it for now. Once
trixie stops being interesting to build it can be readded.

This reverts commit 9a68d026e5345847810a8a8a1871699f0f2d3181.

4 weeks agoci: Add claude-review workflow
Daan De Meyer [Tue, 10 Mar 2026 13:46:22 +0000 (14:46 +0100)] 
ci: Add claude-review workflow

Same as in systemd repo, allows asking claude to review pull requests.
While we're at it, add some instructions for agents when working with
the mkosi repository.

4 weeks agodebian: use new tpm2-tss metapackage instead of library packages
Luca Boccassi [Mon, 9 Mar 2026 23:15:55 +0000 (23:15 +0000)] 
debian: use new tpm2-tss metapackage instead of library packages

This new package depends on all the library packages, so it doesn't
have to be updated, and doesn't need to use complex apt regexes

4 weeks agomkosi-tools: Drop newuidmap/newgidmap
Daan De Meyer [Mon, 9 Mar 2026 11:00:24 +0000 (12:00 +0100)] 
mkosi-tools: Drop newuidmap/newgidmap

Not needed anymore now that we use the foreign UID range and nsresourced.

4 weeks agoUse userdbd creds instead of manual useradd call for mkosi user
Luca Boccassi [Mon, 2 Mar 2026 22:49:16 +0000 (22:49 +0000)] 
Use userdbd creds instead of manual useradd call for mkosi user

This helps dogfooding one more bit of systemd, and also makes it
resilient to a factory reset.
userdbd was introduced in v245 in 2019, so should be fine to use.

https://systemd.io/USER_RECORD/

4 weeks agoMerge pull request #4209 from daandemeyer/creds
Luca Boccassi [Mon, 9 Mar 2026 10:14:24 +0000 (10:14 +0000)] 
Merge pull request #4209 from daandemeyer/creds

Rework credential serialization/deserialization

4 weeks agoRework credential serialization/deserialization 4209/head
Daan De Meyer [Mon, 9 Mar 2026 08:43:10 +0000 (09:43 +0100)] 
Rework credential serialization/deserialization

Currently this is lossy as paths are deserialized as strings instead
of Paths. Make this non-lossy by introducing a dataclass and a special
serialization format.

4 weeks agoNEWS: fix typo flagged by codespell
Luca Boccassi [Mon, 9 Mar 2026 01:10:09 +0000 (01:10 +0000)] 
NEWS: fix typo flagged by codespell

5 weeks agoStore outputs in config directory by default
Daan De Meyer [Thu, 26 Feb 2026 19:03:20 +0000 (20:03 +0100)] 
Store outputs in config directory by default

If no output location is explicitly configured and we have a mkosi/
subdirectory, let's store the .mkosi-private directory and the tools
tree and everything else there instead of in the top level directory.

5 weeks agoFix error checks for nsresource_allocate_user_range()
Daan De Meyer [Mon, 2 Mar 2026 17:22:16 +0000 (18:22 +0100)] 
Fix error checks for nsresource_allocate_user_range()

We have to check for VarlinkError(org.varlink.service.InvalidParameter)
instead of errno.EINVAL. While we're at it, check for FileNotFoundError
instead of OSError(ENOENT) as well.

5 weeks agoAdd support for using the foreign UID range for directory images
Daan De Meyer [Thu, 12 Feb 2026 10:45:01 +0000 (11:45 +0100)] 
Add support for using the foreign UID range for directory images

systemd recently introduced the foreign UID range to enable unprivileged
nspawn containers using directory rootfs trees. Let's get rid of all our
hacks to get directory images booting in nspawn and qemu and instead insist
on the foreign UID range when booting directory images.

Because the foreign UID range is rather new, we don't insist on using it
to build images. The new ForeignUIDRange= option has to be enabled to make
use of the foreign UID range. When enabled, we'll enter a user namespace
with the foreign UID range mapped into it when building an image and use
systemd-dissect at the end of the image build to recursively chown the
directory image to the foreign UID range.

run_clean() now needs access to the foreign UID range to remove directory
trees owned by the foreign UID range so we run it with fork_and_wait() as
well now.

To get access to the foreign UID range, we use a few extensions to
AllocateUserRange() from systemd-nsresourced which means we add a minimal
varlink implementation to sandbox.py.

To boot directory images with systemd-nspawn and systemd-vmspawn, we have
to delegate a transient UID range to the mkosi sandbox so that it can be
allocated to systemd-nspawn as a transient UID range by systemd-nsresourced.

For mkosi qemu, we have to set things up for virtiofsd ourselves which we
do with the new --bind-foreign option for mkosi-sandbox in which case it does
the same setup that vmspawn does for virtiofsd itself.

Because we don't use newuidmap/newgidmap anymore in run_qemu() now, there's no
need to run image builds in a fork anymore. Instead, we can join a user namespace
with some delegated UID ranges and the foreign UID range which will suffice both
for the image builds and for nspawn/vmspawn/qemu. So this commit also gets rid of
various uses of fork_and_wait() across the codebase which aren't required anymore.

All the foreign UID range functionality will require systemd v260 or newer,
specifically the following PRs:
- https://github.com/systemd/systemd/pull/40212
- https://github.com/systemd/systemd/pull/40564
- https://github.com/systemd/systemd/pull/40415

5 weeks agoMake sure udev is installed in mkosi's tools tree
Daan De Meyer [Fri, 27 Feb 2026 09:34:32 +0000 (10:34 +0100)] 
Make sure udev is installed in mkosi's tools tree

We need udevadm for the LVM integration tests for mkosi-initrd.

5 weeks agomkosi-vm: Install libseccomp2 in debian
Daan De Meyer [Fri, 27 Feb 2026 08:05:44 +0000 (09:05 +0100)] 
mkosi-vm: Install libseccomp2 in debian

5 weeks agodebian: Install passwd
Daan De Meyer [Fri, 27 Feb 2026 07:47:27 +0000 (08:47 +0100)] 
debian: Install passwd

5 weeks agodebian: Install mount explicitly
Daan De Meyer [Thu, 26 Feb 2026 19:29:51 +0000 (20:29 +0100)] 
debian: Install mount explicitly

Not pulled in by default anymore.

5 weeks agoAllow nesting mkosi box both sessions and indicate nesting in prompt
Kai Lüke [Tue, 24 Feb 2026 14:38:33 +0000 (23:38 +0900)] 
Allow nesting mkosi box both sessions and indicate nesting in prompt

So far nesting mkosi box was forbidden because it's confusing if there
is no indicator. For scripts running commands it would not be an issue,
though, and one would force MKOSI_IN_BOX=0 for that. But with
SHELL_PROMPT_PREFIX becomming common we can now indicate the current
level of nesting.
Allow mkosi box nesting for both interactive and scripted usage without
requring a MKOSI_IN_BOX overwrite. Indicate the current nesting level in
the shell prompt.

Co-authored-by: Jörg Behrmann <behrmann@physik.fu-berlin.de>
5 weeks agoSet set -x in the scripts where we so far did not
Jörg Behrmann [Thu, 26 Feb 2026 20:21:16 +0000 (21:21 +0100)] 
Set set -x in the scripts where we so far did not

5 weeks agoAppend ExtraSearchPaths= to $PYTHONPATH in mkosi box
Daan De Meyer [Thu, 26 Feb 2026 18:48:45 +0000 (19:48 +0100)] 
Append ExtraSearchPaths= to $PYTHONPATH in mkosi box

Allows easy access to various other python projects on disk from
within a mkosi box environment.

5 weeks agoDon't override PYTHONPATH in bin/mkosi
Daan De Meyer [Thu, 26 Feb 2026 18:27:37 +0000 (19:27 +0100)] 
Don't override PYTHONPATH in bin/mkosi

6 weeks agozypper: Use --oldpackage when downgrading packages is allowed
Petr Pavlu [Fri, 20 Feb 2026 16:35:49 +0000 (17:35 +0100)] 
zypper: Use --oldpackage when downgrading packages is allowed

Commit 78f155bb ("Add support for downgrading when installing volatile
packages") introduced the allow_downgrade parameter to the
PackageManager.install() method. The motivation for adding this parameter
was to ensure that when updating volatile packages, mkosi can install
a local package even if it is older that what the distribution provides.

For zypper, the parameter was implemented by adding the --allow-downgrade
option to the tool's install command. However, this doesn't work fully and
volatiles packages might not be properly updated. The issue is that even
though the --allow-downgrade option allows the solver to downgrade
installed packages, zypper rejects the operation if the selected package is
not the latest version available in the repositories.

To force the installation of an older package, zypper additionally provides
the --oldpackage option. Use this option in Zypper.install() for correctly
updating volatile packages.

6 weeks agomkosi-tools: Install dnf5 on debian when available
Daan De Meyer [Mon, 23 Feb 2026 13:41:57 +0000 (14:41 +0100)] 
mkosi-tools: Install dnf5 on debian when available

6 weeks agokmod: actually ignore missing module deps
Clayton Craft [Fri, 20 Feb 2026 19:06:57 +0000 (11:06 -0800)] 
kmod: actually ignore missing module deps

Prior to f9e7527e, IIUC modules in todo were ignored when they were
popped and `moddep.get(m)` returned None for any modules that were
missin. After f9e7527e, missing modules aren't actually ignored, which
leads to e.g.:

```
‣ aes is a dependency of cifs but is not installed, ignoring
‣ nls is a dependency of cifs but is not installed, ignoring
‣ aead2 is a dependency of cifs but is not installed, ignoring
modinfo: ERROR: Module name nls not found.
```

(nls.ko doesn't exist, and shouldn't exist in recent (6.19-ish) kernel
trees)

7 weeks agoAdd back accidentally dropped kernel command line argument
Daan De Meyer [Thu, 19 Feb 2026 16:31:16 +0000 (17:31 +0100)] 
Add back accidentally dropped kernel command line argument

7 weeks agoMerge pull request #4183 from daandemeyer/hostname
Daan De Meyer [Thu, 19 Feb 2026 13:43:24 +0000 (14:43 +0100)] 
Merge pull request #4183 from daandemeyer/hostname

7 weeks agoStop setting hostname via kernel command line 4183/head
Daan De Meyer [Thu, 19 Feb 2026 13:00:52 +0000 (14:00 +0100)] 
Stop setting hostname via kernel command line

This overrides the hostname from other sources, such as the nspawn
config file. Given we have DEFAULT_HOSTNAME= now, let's have users
use that and stop setting it explicitly ourselves.

7 weeks agoSkip all kernel cmdline options that don't apply to containers
Daan De Meyer [Thu, 19 Feb 2026 12:59:18 +0000 (13:59 +0100)] 
Skip all kernel cmdline options that don't apply to containers

7 weeks agonspawn: Add --suppress-sync=yes by default
Daan De Meyer [Thu, 19 Feb 2026 10:28:55 +0000 (11:28 +0100)] 
nspawn: Add --suppress-sync=yes by default

We're doing development containers, so making sure changes actually
hit the disk isn't all that important. Let's add --suppress-sync=yes
by default to speed things up. This prevents
systemd-machine-id-commit.service from delaying the boot by 5s every
first boot of a container.

7 weeks agoDefault Machine= to the current working directory name
Daan De Meyer [Wed, 18 Feb 2026 14:30:29 +0000 (15:30 +0100)] 
Default Machine= to the current working directory name

It makes a lot more sense for the systemd machine name to be systemd
rather than main.

7 weeks agoconfig: exclude multiple inheritance from JSON loading typing
Jörg Behrmann [Wed, 18 Feb 2026 13:07:05 +0000 (14:07 +0100)] 
config: exclude multiple inheritance from JSON loading typing

As pointed out in [1], the reason that ty cannot infer that the assignment of
the dict instance s to the dict j when loading JSON after checking that s is
instance of dict, is because multiple inheritance is a thing and the passed in
object could be a dict that doesn't have string keys, but does have a read
method. So let's be explicit and disallow these unhandled cases. This also
fixes that the order of these branches is not stable against reordering with
pyright and type checking fails if e.g. the check for the read attribute is
moved above the dict instance check.

[1] https://github.com/astral-sh/ty/issues/1475#issuecomment-3916505245
[2] https://github.com/astral-sh/ty/issues/1578

7 weeks agovmspawn: Set --tpm-state=off
Daan De Meyer [Wed, 18 Feb 2026 13:18:44 +0000 (14:18 +0100)] 
vmspawn: Set --tpm-state=off

Otherwise we'll leave the tpm state lingering around. For now let's
disable tpm state saving.

7 weeks agoSupport glob expansion for path list config options
alexhulbert [Tue, 17 Feb 2026 19:48:37 +0000 (14:48 -0500)] 
Support glob expansion for path list config options

7 weeks agoMerge pull request #4177 from behrmann/misc
Jörg Behrmann [Mon, 16 Feb 2026 14:58:41 +0000 (15:58 +0100)] 
Merge pull request #4177 from behrmann/misc

Various typing things

7 weeks agoconfig: annotate json object before assignment 4177/head
Jörg Behrmann [Mon, 16 Feb 2026 12:17:26 +0000 (13:17 +0100)] 
config: annotate json object before assignment

This makes comments from type checkers clearer in this case, since the type is
clear before it is first assignment, but what is assigned to the object comes
from different functions.

7 weeks agoconfig: annotate all type ignore comments by what tool needs them
Jörg Behrmann [Mon, 16 Feb 2026 12:17:12 +0000 (13:17 +0100)] 
config: annotate all type ignore comments by what tool needs them

7 weeks agoconfig: use typing.get_args instead of private fields
Jörg Behrmann [Mon, 16 Feb 2026 12:14:24 +0000 (13:14 +0100)] 
config: use typing.get_args instead of private fields

This allows us to get rid of one type ignore comment.

7 weeks agorun: remove unneded type ignore comment
Jörg Behrmann [Mon, 16 Feb 2026 12:14:06 +0000 (13:14 +0100)] 
run: remove unneded type ignore comment

7 weeks agoman: number all points in CACHING with 1.
Jörg Behrmann [Mon, 16 Feb 2026 11:58:09 +0000 (12:58 +0100)] 
man: number all points in CACHING with 1.

Same EXECUTION FLOW

7 weeks agoman: Update caching section
Daan De Meyer [Mon, 16 Feb 2026 09:18:28 +0000 (10:18 +0100)] 
man: Update caching section

7 weeks agoRemove all cached images if repository metadata will be synced
Daan De Meyer [Mon, 16 Feb 2026 08:05:54 +0000 (09:05 +0100)] 
Remove all cached images if repository metadata will be synced

If we don't do this, and packages are installed in postinstall scripts,
we can end up in partial upgrade situations, where we install packages
that depend on newer versions of libraries that are installed. This is
particularly a problem on Arch Linux, which explicitly does not support
partial upgrades.

To solve the issue, if we decide we need to sync repository metadata,
remove all cached images.

To avoid removing syncing repository metadata (and thus removing all
cached images) when a cached image is invalidated, CacheOnly=metadata
can be configured for the image.

7 weeks agoMove Incremental= to inherited settings in docs
Daan De Meyer [Sat, 14 Feb 2026 21:47:49 +0000 (22:47 +0100)] 
Move Incremental= to inherited settings in docs

7 weeks agoMake MakeScriptsExecutable= a multiversal setting
Daan De Meyer [Sat, 14 Feb 2026 21:47:36 +0000 (22:47 +0100)] 
Make MakeScriptsExecutable= a multiversal setting

7 weeks agoLook at all CacheOnly= settings to determine if we need to sync metadata
Daan De Meyer [Sat, 14 Feb 2026 21:37:43 +0000 (22:37 +0100)] 
Look at all CacheOnly= settings to determine if we need to sync metadata

Instead of only looking at the CacheOnly= setting of the main image,
let's allow subimages to also configure it to instruct whether repository
metadata should be synced for that image or not.

Also, let's change the behavior of "auto". Currently, we don't sync
repository metadata as long as we have a cached image. The idea behind
this was to avoid weird problems when installing packages in postinst
scripts or such that would see newer repository metadata than the repository
metadata that the image was built with.

While this still holds, the problem with the current approach is that
for regular uses, the default initrd will always have a cache and as such,
even when the main image is out-of-date, we still won't sync repository metadata,
eventually resulting in the repository metadata being so out of date that
the packages can't be found in the mirrors anymore.

The latter is much more likely to happen than the former, so let's sync
repository metadata every time we have any image that does not have a cache.
The user now has the option to customize the behavior per image if they don't
like the default behavior.

7 weeks agoconfig / qemu: add Console=headless
Gregory Price [Fri, 23 Jan 2026 19:48:09 +0000 (14:48 -0500)] 
config / qemu: add Console=headless

Add a headless option for Console so automation can run the qemu
instance in a background task.  In the current modes, qemu just
exits on boot because the console has nothing to attach to.

vmspawn does not support headless for now, just die if this is set.

Signed-off-by: Gregory Price <gourry@gourry.net>
7 weeks agosandbox: Make sure eventfd is CLOEXEC
Daan De Meyer [Sat, 14 Feb 2026 13:40:18 +0000 (14:40 +0100)] 
sandbox: Make sure eventfd is CLOEXEC

7 weeks agoMerge pull request #4169 from daandemeyer/python3.9
Daan De Meyer [Sat, 14 Feb 2026 13:47:11 +0000 (14:47 +0100)] 
Merge pull request #4169 from daandemeyer/python3.9

7 weeks agoRevert "Bump minimum python version to 3.10" 4169/head
Daan De Meyer [Sat, 14 Feb 2026 13:24:29 +0000 (14:24 +0100)] 
Revert "Bump minimum python version to 3.10"

This reverts commit 22b2f0bf18ac98f62ef92745fde5dd3f8369d4bf.

Turns out using python3.12 on CentOS causes more issues than
we thought it would, so let's revert the move to python 3.9.
Instead, we'll conditionally import Union in sandbox.py only on
python 3.9 and use the Union operator otherwise.

7 weeks agoRevert "sandbox: Use os.eventfd()"
Daan De Meyer [Sat, 14 Feb 2026 12:37:08 +0000 (13:37 +0100)] 
Revert "sandbox: Use os.eventfd()"

This reverts commit 1505d67efe3457a041a29e7a6516d1d0173833ef.

7 weeks agoRevert "Use python3.12 as interpreter in CentOS Stream 9 zipapp"
Daan De Meyer [Sat, 14 Feb 2026 12:36:48 +0000 (13:36 +0100)] 
Revert "Use python3.12 as interpreter in CentOS Stream 9 zipapp"

This reverts commit d6ddc66acb05d3d761d3f600c6b029319db9ae95.