Add no-nvidia and nouveau specialization on omen

Signed-off-by: magic_rb <magic_rb@redalder.org>
This commit is contained in:
magic_rb 2023-12-24 17:01:41 +01:00
parent 69eb47c2a1
commit 9413748603
No known key found for this signature in database
GPG key ID: 08D5287CC5DDCA0E

View file

@ -1,15 +1,24 @@
# SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk> # SPDX-FileCopyrightText: 2022 Richard Brežák <richard@brezak.sk>
# #
# SPDX-License-Identifier: LGPL-3.0-or-later # SPDX-License-Identifier: LGPL-3.0-or-later
{ pkgs, lib, inputs', ... }: {
let pkgs,
inherit (lib) lib,
inputs',
options,
...
}: let
inherit
(lib)
singleton singleton
mkForce; mkForce
mapAttrs
mkOverride
filter
;
kernelPackages = pkgs.zfsUnstable.latestCompatibleLinuxPackages; kernelPackages = pkgs.zfsUnstable.latestCompatibleLinuxPackages;
in in {
{
environment.systemPackages = [ environment.systemPackages = [
kernelPackages.turbostat kernelPackages.turbostat
]; ];
@ -52,6 +61,9 @@ in
hardware.tuxedo-keyboard.enable = true; hardware.tuxedo-keyboard.enable = true;
specialisation.nvidia-sync.configuration = { specialisation.nvidia-sync.configuration = {
environment.variables.NIXOS_SPECIALIZATION = "nvidia-sync";
boot.loader.grub.enable = mkOverride 0 false;
hardware.nvidia = { hardware.nvidia = {
powerManagement.enable = mkForce false; powerManagement.enable = mkForce false;
powerManagement.finegrained = 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 = { hardware.nvidia = {
nvidiaPersistenced = true; nvidiaPersistenced = true;