69 lines
2.7 KiB
Nix
69 lines
2.7 KiB
Nix
# 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")
|
||
];
|
||
|
||
# 1) Make sure modules are available early so the probe can succeed
|
||
boot.initrd.kernelModules = [ "vfio" "vfio_pci" "vfio_iommu_type1" "ahci" ];
|
||
|
||
# 2) Also load them again in the running system
|
||
boot.kernelModules = [ "vfio" "vfio_pci" "vfio_iommu_typoe1" "ahci" ];
|
||
|
||
# 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"
|
||
];
|
||
|
||
boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "usbhid" "sd_mod" ];
|
||
|
||
# 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'"
|
||
'';
|
||
|
||
boot.kernel.sysctl."net.ipv4.conf.all.forwarding" = true;
|
||
|
||
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;
|
||
|
||
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;
|
||
}
|