From 9413748603399114b1bcb9a687e4f85b253558c8 Mon Sep 17 00:00:00 2001 From: magic_rb Date: Sun, 24 Dec 2023 17:01:41 +0100 Subject: [PATCH] Add no-nvidia and nouveau specialization on omen Signed-off-by: magic_rb --- nixos/systems/omen/hardware.nix | 73 ++++++++++++++++++++++++++++++--- 1 file changed, 67 insertions(+), 6 deletions(-) diff --git a/nixos/systems/omen/hardware.nix b/nixos/systems/omen/hardware.nix index 4aed04f..7712d65 100644 --- a/nixos/systems/omen/hardware.nix +++ b/nixos/systems/omen/hardware.nix @@ -1,15 +1,24 @@ # SPDX-FileCopyrightText: 2022 Richard Brežák # # SPDX-License-Identifier: LGPL-3.0-or-later -{ pkgs, lib, inputs', ... }: -let - inherit (lib) +{ + pkgs, + lib, + inputs', + options, + ... +}: let + inherit + (lib) singleton - mkForce; + mkForce + mapAttrs + mkOverride + filter + ; kernelPackages = pkgs.zfsUnstable.latestCompatibleLinuxPackages; -in -{ +in { environment.systemPackages = [ kernelPackages.turbostat ]; @@ -52,6 +61,9 @@ in hardware.tuxedo-keyboard.enable = true; specialisation.nvidia-sync.configuration = { + environment.variables.NIXOS_SPECIALIZATION = "nvidia-sync"; + boot.loader.grub.enable = mkOverride 0 false; + hardware.nvidia = { powerManagement.enable = mkForce false; powerManagement.finegrained = mkForce false; @@ -61,6 +73,55 @@ in }; }; + specialisation.nouveau.configuration = { + environment.variables.NIXOS_SPECIALIZATION = "nouveau"; + boot.loader.grub.enable = mkOverride 0 false; + + hardware.nvidia = mapAttrs (_: v: mkForce v) { + powerManagement.enable = false; + powerManagement.finegrained = false; + prime.offload.enableOffloadCmd = false; + prime.offload.enable = false; + nvidiaPersistenced = false; + + prime.reverseSync.enable = false; + }; + services.xserver.videoDrivers = mkForce ["modesetting" "nouveau"]; + }; + + specialisation.no-nvidia.configuration = { + environment.variables.NIXOS_SPECIALIZATION = "no-nvidia"; + boot.loader.grub.enable = mkOverride 0 false; + + hardware.nvidia = mapAttrs (_: v: mkForce v) { + powerManagement.enable = false; + powerManagement.finegrained = false; + prime.offload.enableOffloadCmd = false; + prime.offload.enable = false; + nvidiaPersistenced = false; + + prime.reverseSync.enable = false; + }; + services.xserver.videoDrivers = mkForce ["modesetting"]; + + boot.extraModprobeConfig = '' + blacklist nouveau + options nouveau modeset=0 + ''; + + services.udev.extraRules = '' + # Remove NVIDIA USB xHCI Host Controller devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{power/control}="auto", ATTR{remove}="1" + # Remove NVIDIA USB Type-C UCSI devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c8000", ATTR{power/control}="auto", ATTR{remove}="1" + # Remove NVIDIA Audio devices, if present + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x040300", ATTR{power/control}="auto", ATTR{remove}="1" + # Remove NVIDIA VGA/3D controller devices + ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x03[0-9]*", ATTR{power/control}="auto", ATTR{remove}="1" + ''; + boot.blacklistedKernelModules = ["nouveau" "nvidia" "nvidia_drm" "nvidia_modeset"]; + }; + hardware.nvidia = { nvidiaPersistenced = true;