2025-01-13 00:46:22 +01:00
|
|
|
|
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
|
|
|
|
|
# and may be overwritten by future invocations. Please make changes
|
|
|
|
|
|
# to /etc/nixos/configuration.nix instead.
|
|
|
|
|
|
{ config, lib, pkgs, modulesPath, ... }:
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
imports =
|
|
|
|
|
|
[ (modulesPath + "/installer/scan/not-detected.nix")
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2025-11-04 21:53:55 +01:00
|
|
|
|
# 1) Make sure modules are available early so the probe can succeed
|
|
|
|
|
|
boot.initrd.kernelModules = [ "vfio" "vfio_pci" "vfio_iommu_type1" "ahci" ];
|
2025-07-22 10:25:34 +02:00
|
|
|
|
|
|
|
|
|
|
# 2) Also load them again in the running system
|
2025-11-04 21:53:55 +01:00
|
|
|
|
boot.kernelModules = [ "vfio" "vfio_pci" "vfio_iommu_typoe1" "ahci" ];
|
2025-07-22 10:25:34 +02:00
|
|
|
|
|
|
|
|
|
|
# 3) Kernel params to turn on IOMMU and bind your card to vfio-pci
|
|
|
|
|
|
boot.kernelParams = lib.mkForce [
|
|
|
|
|
|
# for AMD hosts (use the intel line if you’re on Intel)
|
|
|
|
|
|
"amd_iommu=on"
|
|
|
|
|
|
"iommu=pt"
|
|
|
|
|
|
|
|
|
|
|
|
# helps isolate PCIe ports if your card shares groups
|
|
|
|
|
|
"pci_acs_override=downstream,multifunction"
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2025-01-13 00:46:22 +01:00
|
|
|
|
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ];
|
|
|
|
|
|
|
2025-11-04 21:53:55 +01:00
|
|
|
|
# Bind per-device via udev using driver_override and drivers_probe
|
|
|
|
|
|
services.udev.extraRules = ''
|
|
|
|
|
|
# Bind 0000:09:00.0 to vfio-pci
|
|
|
|
|
|
ACTION=="add", SUBSYSTEM=="pci", KERNEL=="0000:09:00.0", \
|
|
|
|
|
|
ATTR{driver_override}="vfio-pci", \
|
|
|
|
|
|
RUN+="/bin/sh -c 'modprobe vfio-pci; echo 0000:09:00.0 > /sys/bus/pci/drivers_probe'"
|
|
|
|
|
|
|
|
|
|
|
|
# Bind 0000:08:00.0 to ahci (host)
|
|
|
|
|
|
ACTION=="add", SUBSYSTEM=="pci", KERNEL=="0000:08:00.0", \
|
|
|
|
|
|
ATTR{driver_override}="ahci", \
|
|
|
|
|
|
RUN+="/bin/sh -c 'modprobe ahci; echo 0000:08:00.0 > /sys/bus/pci/drivers_probe'"
|
|
|
|
|
|
'';
|
|
|
|
|
|
|
2025-07-31 08:59:16 +02:00
|
|
|
|
boot.kernel.sysctl."net.ipv4.conf.all.forwarding" = true;
|
|
|
|
|
|
|
2025-01-13 00:46:22 +01:00
|
|
|
|
swapDevices =
|
|
|
|
|
|
[ { device = "/dev/disk/by-uuid/7e34cdc3-bd48-435a-8ea2-e1fe43926262"; }
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
|
|
|
|
|
# (the default) this is the recommended approach. When using systemd-networkd it's
|
|
|
|
|
|
# still possible to use this option, but it's recommended to use it in conjunction
|
|
|
|
|
|
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
|
|
|
|
|
networking.useDHCP = lib.mkDefault true;
|
|
|
|
|
|
# networking.interfaces.enp3s0.useDHCP = lib.mkDefault true;
|
|
|
|
|
|
|
|
|
|
|
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
|
|
|
|
|
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
2025-07-22 10:25:34 +02:00
|
|
|
|
|
|
|
|
|
|
services.xserver.videoDrivers = [ "nvidia" ];
|
|
|
|
|
|
hardware.nvidia = {
|
|
|
|
|
|
package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
|
|
|
|
|
|
modesetting.enable = true;
|
|
|
|
|
|
powerManagement.enable = true;
|
|
|
|
|
|
open = false; # <--- this must be false for proprietary
|
|
|
|
|
|
nvidiaSettings = true;
|
|
|
|
|
|
};
|
|
|
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
|
|
nixpkgs.config.nvidia.acceptLicense = true;
|
2025-01-13 00:46:22 +01:00
|
|
|
|
}
|