devices.pc: switch to amd+nvidia sync

This commit is contained in:
2024-03-07 12:54:16 +08:00
parent b07e09c94e
commit b45c68a431
2 changed files with 34 additions and 14 deletions

View File

@@ -60,7 +60,12 @@ inputs:
hardware =
{
cpus = [ "amd" ];
gpu = { type = "nvidia"; dynamicBoost = true; };
gpu =
{
type = "amd+nvidia";
prime = { mode = "sync"; busId = { amd = "8:0:0"; nvidia = "1:0:0"; }; };
dynamicBoost = true;
};
bluetooth.enable = true;
joystick.enable = true;
printer.enable = true;
@@ -133,7 +138,7 @@ inputs:
publicKey = "l1gFSDCeBxyf/BipXNvoEvVvLqPgdil84nmr5q6+EEw=";
wireguardIp = "192.168.83.3";
};
gamemode = { enable = true; drmDevice = 0; };
gamemode = { enable = true; drmDevice = 1; };
slurm = { enable = true; cpu = { cores = 16; threads = 2; }; memoryMB = 94208; gpus."4060" = 1; };
xrdp = { enable = true; hostname = [ "pc.chn.moe" ]; };
};
@@ -141,15 +146,22 @@ inputs:
};
services.colord.enable = true;
virtualisation.virtualbox.host = { enable = true; enableExtensionPack = true; };
specialisation.hybrid.configuration =
specialisation =
{
nixos =
nvidia.configuration =
{
hardware.gpu =
{ type = inputs.lib.mkForce "amd+nvidia"; prime.busId = { amd = "8:0:0"; nvidia = "1:0:0"; }; };
services.gamemode.drmDevice = inputs.lib.mkForce 1;
nixos =
{
hardware.gpu.type = inputs.lib.mkForce "nvidia";
services.gamemode.drmDevice = inputs.lib.mkForce 0;
};
system.nixos.tags = [ "nvidia" ];
};
hybrid-offload.configuration =
{
nixos.hardware.gpu.prime.mode = inputs.lib.mkForce "offload";
system.nixos.tags = [ "hybrid-offload" ];
};
system.nixos.tags = [ "hybrid-graphic" ];
};
};
}

View File

@@ -14,7 +14,11 @@ inputs:
default = null;
};
dynamicBoost = mkOption { type = types.bool; default = false; };
prime.busId = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
prime =
{
mode = mkOption { type = types.enum [ "offload" "sync" ]; default = "offload"; };
busId = mkOption { type = types.attrsOf types.nonEmptyStr; default = {}; };
};
};
config = let inherit (inputs.config.nixos.hardware) gpu; in inputs.lib.mkIf (gpu.type != null) (inputs.lib.mkMerge
[
@@ -76,11 +80,15 @@ inputs:
(
inputs.lib.mkIf (inputs.lib.strings.hasSuffix "+nvidia" gpu.type) { hardware.nvidia =
{
prime = { offload = { enable = true; enableOffloadCmd = 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 = true;
prime =
{
offload = inputs.lib.mkIf (gpu.prime.mode == "offload") { enable = true; enableOffloadCmd = true; };
sync = inputs.lib.mkIf (gpu.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;
};}
)
]);