From 614b54d9b04092d6926afd49d64efe86272f7dd1 Mon Sep 17 00:00:00 2001 From: polykernel <81340136+polykernel@users.noreply.github.com> Date: Sun, 3 Oct 2021 17:14:03 -0400 Subject: [PATCH] hardware/nvidia: stricter constraints on PCI bus-id. The current type for the busId options are too relaxed, a stricter constraint should be imposed to guard against typos which result in Xorg unable to start. This commit restricts the type to adhere to the B/D/F notation[1] for addressing devices as expected by the module option. [1] - https://wiki.osdev.org/PCI#Configuration_Space_Access_Mechanism_.231 --- nixos/modules/hardware/video/nvidia.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nixos/modules/hardware/video/nvidia.nix b/nixos/modules/hardware/video/nvidia.nix index 6de5b99a1ee6..c7c440bea19c 100644 --- a/nixos/modules/hardware/video/nvidia.nix +++ b/nixos/modules/hardware/video/nvidia.nix @@ -68,7 +68,7 @@ in }; hardware.nvidia.prime.nvidiaBusId = mkOption { - type = types.str; + type = types.strMatching "[[:print:]]+\:[0-9]{1,3}\:[0-9]{1,2}\:[0-9]"; default = ""; example = "PCI:1:0:0"; description = '' @@ -78,7 +78,7 @@ in }; hardware.nvidia.prime.intelBusId = mkOption { - type = types.str; + type = types.strMatching "[[:print:]]+\:[0-9]{1,3}\:[0-9]{1,2}\:[0-9]"; default = ""; example = "PCI:0:2:0"; description = '' @@ -88,7 +88,7 @@ in }; hardware.nvidia.prime.amdgpuBusId = mkOption { - type = types.str; + type = types.strMatching "[[:print:]]+\:[0-9]{1,3}\:[0-9]{1,2}\:[0-9]"; default = ""; example = "PCI:4:0:0"; description = ''