Files
nixos-config/hosts/snowfire/hardware-configuration.nix
2025-09-13 21:03:34 -05:00

145 lines
5.1 KiB
Nix
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 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, inputs, ... }:
{
imports =
[ (modulesPath + "/installer/scan/not-detected.nix")
];
services.fstrim.enable = true;
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" "usb_storage" "sd_mod" "radeon" ];
boot.initrd.kernelModules = [ "radeon" ];
boot.kernelModules = [ "kvm-amd" "radeon" "zenpower" "8812au" ];
boot.blacklistedKernelModules = [ "k10temp" ];
boot.kernelParams = [ "amd_pstate=active" "acpi_osi=Linux" "acpi_wake=USB0" ];
boot.extraModulePackages = with config.boot.kernelPackages; [ zenpower ];
networking.wireguard.enable = true;
# https://wiki.nixos.org/wiki/Mesa
hardware = {
graphics =
let
fn = oa: {
nativeBuildInputs = oa.nativeBuildInputs ++ [ pkgs.glslang ];
mesonFlags = oa.mesonFlags ++ [ "-Dvulkan-layers=device-select,overlay" ];
# patches = oa.patches ++ [ ./mesa-vulkan-layer-nvidia.patch ]; See below
postInstall = oa.postInstall + ''
mv $out/lib/libVkLayer* $drivers/lib
#Device Select layer
layer=VkLayer_MESA_device_select
substituteInPlace $drivers/share/vulkan/implicit_layer.d/''${layer}.json \
--replace "lib''${layer}" "$drivers/lib/lib''${layer}"
#Overlay layer
layer=VkLayer_MESA_overlay
substituteInPlace $drivers/share/vulkan/explicit_layer.d/''${layer}.json \
--replace "lib''${layer}" "$drivers/lib/lib''${layer}"
'';
};
in
with pkgs; {
enable = true;
enable32Bit = true;
package = (mesa.overrideAttrs fn).drivers;
package32 = (pkgsi686Linux.mesa.overrideAttrs fn).drivers;
extraPackages = with pkgs; [ amdvlk ];
extraPackages32 = with pkgs; [ driversi686Linux.amdvlk ];
};
};
hardware.opengl.extraPackages = [ pkgs.rocmPackages.clr.icd ];
hardware.opengl.extraPackages32 = [ ];
#environment.systemPackages = with pkgs.rocmPackages; [ hipcc hip-common hiprand hipblas hipfft hipcub hipify ];
environment.systemPackages = with pkgs.rocmPackages; [ hipcc hip-common hiprand hipfft hipcub hipify ];
services.xserver.videoDrivers = lib.mkDefault [ "modesetting" ];
hardware.amdgpu.initrd.enable = true;
hardware.amdgpu.opencl.enable = true;
hardware.amdgpu.amdvlk.enable = true;
# makes disk io not freeze the computer
services.udev.extraRules = ''
ACTION=="add|change", SUBSYSTEM=="block", ENV{ID_SERIAL_SHORT}=="BTKA121225GP512A", ATTR{queue/scheduler}="bfq"
'';
systemd.tmpfiles.rules =
let
rocmEnv = pkgs.symlinkJoin {
name = "rocm-combined";
paths = with pkgs.rocmPackages; [
#rocblas
#hipblas
clr
];
};
in [
"L+ /opt/rocm - - - - ${rocmEnv}"
];
# my stupid usb hub crashes systemct suspend half of the time now
# https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Sleep_hooks
systemd.services.root-suspend = {
enable = true;
description = "Root systemd suspend prehook";
unitConfig = {
Description = "Root systemd suspend prehook";
Before = "sleep.target";
};
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.uhubctl}/bin/uhubctl -a off";
};
wantedBy = [ "sleep.target" ];
};
systemd.services.root-resume = {
enable = true;
description = "Root systemd suspend posthook";
unitConfig = {
Description = "Root systemd suspend posthook";
After = "suspend.target";
};
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.uhubctl}/bin/uhubctl -a on";
};
wantedBy = [ "suspend.target" ];
};
boot.kernel.sysctl = {
"vm.swappiness" = 180;
"vm.vfs_cache_pressure" = 500;
"vm.dirty_background_ratio" = 4;
"vm.dirty_ratio" = 8;
};
fileSystems."/" =
{ device = "/dev/disk/by-uuid/88f5f921-0a64-4711-9d74-e0f8a3a1b3af";
fsType = "ext4";
};
boot.initrd.luks.devices."luks-09f429eb-1add-48da-b3b8-1a811c0d1472".device = "/dev/disk/by-uuid/09f429eb-1add-48da-b3b8-1a811c0d1472";
fileSystems."/boot" =
{ device = "/dev/disk/by-uuid/4695-0F2E";
fsType = "vfat";
options = [ "fmask=0077" "dmask=0077" ];
};
swapDevices = [ ];
# 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.enp4s0.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp5s0.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
}