From ecd1d29d451a8c58902fc3a8d9a13b09e6767b64 Mon Sep 17 00:00:00 2001 From: Sakooooo <78461130+Sakooooo@users.noreply.github.com> Date: Sun, 13 Aug 2023 19:32:50 +0300 Subject: [PATCH] add prime.nix --- modules/hardware/nvidia/default.nix | 3 +++ modules/hardware/nvidia/prime.nix | 39 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 modules/hardware/nvidia/prime.nix diff --git a/modules/hardware/nvidia/default.nix b/modules/hardware/nvidia/default.nix index ca085933..1c563375 100644 --- a/modules/hardware/nvidia/default.nix +++ b/modules/hardware/nvidia/default.nix @@ -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; diff --git a/modules/hardware/nvidia/prime.nix b/modules/hardware/nvidia/prime.nix new file mode 100644 index 00000000..5899e892 --- /dev/null +++ b/modules/hardware/nvidia/prime.nix @@ -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; + }; + }; + }; +}