From 705a43fa41e32100ee3983c9c042dd05ec87af58 Mon Sep 17 00:00:00 2001 From: chn Date: Sat, 8 Jun 2024 11:59:29 +0800 Subject: [PATCH] devices.pc: switch to nvidia 555 driver --- devices/pc/default.nix | 8 ++++++-- flake.lock | 6 +++--- modules/hardware/gpu.nix | 24 ++++++++++++++---------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/devices/pc/default.nix b/devices/pc/default.nix index 6bce7d10..e11ebe29 100644 --- a/devices/pc/default.nix +++ b/devices/pc/default.nix @@ -60,7 +60,11 @@ inputs: sysctl.laptop-mode = 5; gui.enable = true; }; - hardware = { cpus = [ "amd" ]; gpu = { type = "nvidia"; dynamicBoost = true; }; legion = {}; }; + hardware = + { + cpus = [ "amd" ]; + gpu = { type = "nvidia"; nvidia = { dynamicBoost = true; driver = "beta"; }; }; legion = {}; + }; packages.packageSet = "workstation"; virtualization = { @@ -144,7 +148,7 @@ inputs: nixos = { hardware.gpu = - { type = inputs.lib.mkForce "amd+nvidia"; prime.busId = { amd = "6:0:0"; nvidia = "1:0:0"; }; }; + { type = inputs.lib.mkForce "amd+nvidia"; nvidia.prime.busId = { amd = "6:0:0"; nvidia = "1:0:0"; }; }; services.gamemode.drmDevice = inputs.lib.mkForce 1; }; system.nixos.tags = [ "hybrid" ]; diff --git a/flake.lock b/flake.lock index 33007769..c6dad7f9 100644 --- a/flake.lock +++ b/flake.lock @@ -1444,11 +1444,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1717815251, - "narHash": "sha256-wSK6wuBolx9pnNZ3v80MCQnT+bXon0Fan1mpf9peYZc=", + "lastModified": 1717818640, + "narHash": "sha256-VGTlViTvrMJa/ot1Lctbl8pXuT7pRWx/ixR0PypanrY=", "owner": "CHN-beta", "repo": "nixpkgs", - "rev": "292fee7851002d7609eb822c50ecda172c31721a", + "rev": "2a0d2928bd5a2f8e5eda397387c4cff9695b13d4", "type": "github" }, "original": { diff --git a/modules/hardware/gpu.nix b/modules/hardware/gpu.nix index 3460cda2..6a68c12a 100644 --- a/modules/hardware/gpu.nix +++ b/modules/hardware/gpu.nix @@ -13,11 +13,15 @@ inputs: ]); default = null; }; - dynamicBoost = mkOption { type = types.bool; default = false; }; - prime = + nvidia = { - mode = mkOption { type = types.enum [ "offload" "sync" ]; default = "offload"; }; - busId = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; }; + dynamicBoost = mkOption { type = types.bool; default = false; }; + prime = + { + mode = mkOption { type = types.enum [ "offload" "sync" ]; default = "offload"; }; + busId = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; }; + }; + driver = mkOption { type = types.enum [ "production" "beta" ]; default = "production"; }; }; }; config = let inherit (inputs.config.nixos.hardware) gpu; in inputs.lib.mkIf (gpu.type != null) (inputs.lib.mkMerge @@ -57,10 +61,10 @@ inputs: { modesetting.enable = true; powerManagement.enable = true; - dynamicBoost.enable = inputs.lib.mkIf gpu.dynamicBoost true; + dynamicBoost.enable = inputs.lib.mkIf gpu.nvidia.dynamicBoost true; nvidiaSettings = true; forceFullCompositionPipeline = true; - # package = inputs.config.boot.kernelPackages.nvidiaPackages.production; + package = inputs.config.boot.kernelPackages.nvidiaPackages.${gpu.nvidia.driver}; prime.allowExternalGpu = true; }; }; @@ -82,13 +86,13 @@ inputs: { prime = { - offload = inputs.lib.mkIf (gpu.prime.mode == "offload") { enable = true; enableOffloadCmd = true; }; - sync = inputs.lib.mkIf (gpu.prime.mode == "sync") { enable = true; }; + offload = inputs.lib.mkIf (gpu.nvidia.prime.mode == "offload") { enable = true; enableOffloadCmd = true; }; + sync = inputs.lib.mkIf (gpu.nvidia.prime.mode == "sync") { enable = true; }; } // builtins.listToAttrs (builtins.map (gpu: { name = "${if gpu.name == "amd" then "amdgpu" else gpu.name}BusId"; value = "PCI:${gpu.value}"; }) - (inputs.localLib.attrsToList gpu.prime.busId)); - powerManagement.finegrained = inputs.lib.mkIf (gpu.prime.mode == "offload") true; + (inputs.localLib.attrsToList gpu.nvidia.prime.busId)); + powerManagement.finegrained = inputs.lib.mkIf (gpu.nvidia.prime.mode == "offload") true; };} ) ]);