From df3558fe7ee382ce624bfb8dbd254dbf67d6ec08 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 31 Oct 2023 23:32:12 +0100 Subject: [PATCH] [Hardware/Nvidia] add option for easy configuration of Nouveau NvXXXX=Y style config Also enable NvBoost on desktop PCs --- hardware/nvidia/opensource.nix | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/hardware/nvidia/opensource.nix b/hardware/nvidia/opensource.nix index 7f9ddf8..04b425b 100644 --- a/hardware/nvidia/opensource.nix +++ b/hardware/nvidia/opensource.nix @@ -3,6 +3,15 @@ with lib; let cfg = config.aviallon.hardware.nvidia; in { + options.aviallon.hardware.nvidia.nouveau = { + config = mkOption { + description = "nouveau boot config"; + type = with types; attrsOf (nullOr (oneOf [ int string bool ])); + example = { NvBoost = 1; }; + default = {}; + }; + }; + config = mkIf (cfg.enable && cfg.variant == "nouveau") { boot.initrd.kernelModules = [ "nouveau" ]; @@ -11,9 +20,19 @@ in { "nouveau.pstate" = 1; "nouveau.runpm" = 1; "nouveau.modeset" = 1; - "nouveau.config" = "NvBoost=1"; + "nouveau.config" = let + toValue = v: + if isBool v + then toString (if v then 1 else 0) + else toString v; + filteredConfig = filterAttrs (n: v: ! isNull v) cfg.nouveau.config; + configList = mapAttrsToList (n: v: "${n}=${toValue v}") filteredConfig; + configString = concatStringsSep "," configList; + in trace "Nouveau config: ${configString}" configString; }; aviallon.hardware.mesa.enable = mkDefault true; + + aviallon.hardware.nvidia.nouveau.config.NvBoost = ifEnable (!config.aviallon.laptop.enable) true; }; }