I’m trying to pass-through my GPU to a NixOS container for a jellyfin service to use, but I am running into trouble when starting the container while booting the host. The service container@jellyfin.service fails to start with the error message:
systemd-nspawn[2010]: Failed to clone /dev/dri/card1: No such file or directory
If after having booted the host I restart the container with systemctl restart containers@jellyfin.service, the container starts with no issue. I followed the wiki’s “VAAPI with Jellyfin in a NixOS container” instructions to pass through the device, so when the container manages to start, the device is available.
When checking journalctl -b on the host, the container’s error message appears before the kernel emits logs initializing amdgpu. Thus, it seems to me that the device is not available before the container can run, and thus /dev/dri/card1 does not yet exist.
The idea I had for fixing this was to edit the container’s service somehow (?) container@jellyfin.service to have After=dev-dri-card1.device. However, the host system doesn’t seem to create this device on my system, so I would have to create a udev rule to match the GPU device and extend the tags with TAG+="systemd".
In summary, the container works after booting the host only when restarting the container, apparently because the container tries to access /dev/dri/card1 before it is available.
Am I on the right track, or is there a simpler way of doing this?
Thank you in advance.