add prime.nix

This commit is contained in:
Sakooooo 2023-08-13 19:32:50 +03:00
parent 818a763aad
commit ecd1d29d45
Signed by: sako
GPG key ID: 3FD715D87D7725E0
2 changed files with 42 additions and 0 deletions

View file

@ -10,6 +10,9 @@ with lib; let
cfg = config.modules.hardware.nvidia;
busIDType = lib.types.strMatching "([[:print:]]+[\:\@][0-9]{1,3}\:[0-9]{1,2}\:[0-9])?";
in {
imports = [
./prime.nix
];
options.modules.hardware.nvidia = {
enable = mkEnableOption false;
prime.enable = mkEnableOption false;

View file

@ -0,0 +1,39 @@
{
outputs,
options,
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.modules.hardware.nvidia;
busIDType = lib.types.strMatching "([[:print:]]+[\:\@][0-9]{1,3}\:[0-9]{1,2}\:[0-9])?";
in {
options.modules.hardware.nvidia.prime = {
enable = mkEnableOption false;
intelBusId = mkOption {
type = busIDType;
default = "";
};
nvidiaBusId = mkOption {
type = busIDType;
default = "";
};
};
config = mkIf cfg.enable {
hardware.nvidia = {
prime = {
offload = {
enable = cfg.prime;
enableOffloadCmd = cfg.prime;
};
#intelBusId = "PCI:0:2:0";
#nvidiaBusId = "PCI:1:0:0";
intelBusId = cfg.intelBusId;
nvidiaBusId = cfg.nvidiaBusId;
};
};
};
}