From 61f4af216e2ca646dc8cce954ffe840e1028ae6b Mon Sep 17 00:00:00 2001 From: tux Date: Thu, 25 Dec 2025 16:52:40 +0530 Subject: [PATCH] feat(canopus): add vfio kernel modules --- hosts/canopus/default.nix | 66 ++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 29 deletions(-) diff --git a/hosts/canopus/default.nix b/hosts/canopus/default.nix index c091074..a9611e3 100755 --- a/hosts/canopus/default.nix +++ b/hosts/canopus/default.nix @@ -103,40 +103,48 @@ kernelPackages = pkgs.linuxPackages_zen; supportedFilesystems = ["ntfs"]; - initrd.systemd = { - enable = lib.mkForce true; + initrd = { + kernelModules = [ + "vfio_pci" + "vfio" + "vfio_iommu_type1" + ]; - services.wipe-my-fs = { - wantedBy = ["initrd.target"]; - after = ["initrd-root-device.target"]; - before = ["sysroot.mount"]; - unitConfig.DefaultDependencies = "no"; - serviceConfig.Type = "oneshot"; - script = '' - mkdir /btrfs_tmp - mount /dev/disk/by-partlabel/disk-primary-root /btrfs_tmp + systemd = { + enable = lib.mkForce true; - if [[ -e /btrfs_tmp/root ]]; then - mkdir -p /btrfs_tmp/old_roots - timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S") - mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp" - fi + services.wipe-my-fs = { + wantedBy = ["initrd.target"]; + after = ["initrd-root-device.target"]; + before = ["sysroot.mount"]; + unitConfig.DefaultDependencies = "no"; + serviceConfig.Type = "oneshot"; + script = '' + mkdir /btrfs_tmp + mount /dev/disk/by-partlabel/disk-primary-root /btrfs_tmp - delete_subvolume_recursively() { - IFS=$'\n' - for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do - delete_subvolume_recursively "/btrfs_tmp/$i" - done - btrfs subvolume delete "$1" - } + if [[ -e /btrfs_tmp/root ]]; then + mkdir -p /btrfs_tmp/old_roots + timestamp=$(date --date="@$(stat -c %Y /btrfs_tmp/root)" "+%Y-%m-%-d_%H:%M:%S") + mv /btrfs_tmp/root "/btrfs_tmp/old_roots/$timestamp" + fi - for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do - delete_subvolume_recursively "$i" - done + delete_subvolume_recursively() { + IFS=$'\n' + for i in $(btrfs subvolume list -o "$1" | cut -f 9- -d ' '); do + delete_subvolume_recursively "/btrfs_tmp/$i" + done + btrfs subvolume delete "$1" + } - btrfs subvolume create /btrfs_tmp/root - umount /btrfs_tmp - ''; + for i in $(find /btrfs_tmp/old_roots/ -maxdepth 1 -mtime +30); do + delete_subvolume_recursively "$i" + done + + btrfs subvolume create /btrfs_tmp/root + umount /btrfs_tmp + ''; + }; }; };