From 96045f57c424ac34c5a6efe65f6b8bbff193401e Mon Sep 17 00:00:00 2001 From: Andreas Schaafsma Date: Wed, 22 Apr 2026 03:34:10 +0200 Subject: [PATCH] migrate predevicecommands to initrd systemd service --- .../hardware/graphics/passthrough_nvidia.nix | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/systems/x86_64-linux/drivebystation-nix/hardware/graphics/passthrough_nvidia.nix b/systems/x86_64-linux/drivebystation-nix/hardware/graphics/passthrough_nvidia.nix index 18d8375..b5391a8 100644 --- a/systems/x86_64-linux/drivebystation-nix/hardware/graphics/passthrough_nvidia.nix +++ b/systems/x86_64-linux/drivebystation-nix/hardware/graphics/passthrough_nvidia.nix @@ -17,9 +17,23 @@ boot.extraModprobeConfig = '' options vfio-pci ids=10de:1b81,10de:10f0 ''; - boot.initrd.preDeviceCommands = '' - modprobe vfio-pci - ''; + boot.initrd.systemd = { + enable = true; + services.initrd-vfio-pci-nvidia = { + + description = "vfio-pci predevice init"; + wantedBy = [ "initrd.target" ]; + # Match 'preDeviceCommands' by running early + before = [ "sysroot.mount" ]; + + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + + # Place your original shell commands here + script = '' + modprobe vfio-pci + ''; + } # # EARLY and deterministic binding # boot.initrd.preDeviceCommands = '' # echo 0000:05:00.0 > /sys/bus/pci/drivers/vfio-pci/bind