[Unit]
Description=Nucleic: prepare external-kernel modules (depmod + load virtio drivers)
Documentation=https://github.com/ (docs/LINUX_VM.md)
# The base boots an EXTERNAL kernel against a cloud rootfs into which the bootstrap baked the matching
# modules — but with no modules.dep/.alias (the deb ships none; depmod normally runs in the postinst).
# Regenerate them and load the virtio drivers the guest needs (vsock = the agent's control plane; gpu =
# the desktop surface) EARLY, before the vsock agent and systemd-modules-load, so the agent can bind
# AF_VSOCK on the very first boot. Runs every boot; depmod is idempotent and fast.
DefaultDependencies=no
Before=systemd-modules-load.service sysinit.target nucleic-linux-agent.service
After=systemd-remount-fs.service

[Service]
Type=oneshot
RemainAfterExit=yes
# `depmod` (no arg) uses `uname -r` = our external kernel. Then load vsock + gpu (best-effort).
ExecStart=/bin/sh -c 'depmod $(uname -r) 2>/dev/null; modprobe vmw_vsock_virtio_transport 2>/dev/null || modprobe vsock 2>/dev/null; modprobe virtio_gpu 2>/dev/null; true'

[Install]
WantedBy=sysinit.target
