From 856ccd705cb42ccb81db6ba6b8b974d4e29b2edf Mon Sep 17 00:00:00 2001 From: Carson Full Date: Thu, 20 Aug 2026 19:59:16 -0500 Subject: [PATCH] klipper-flash: fix getConfigField across multi-line configs #533030 changed `getConfigField`'s regex to stop it matching commented-out lines, but in doing so broke checking across multiple lines. `builtins.match` requires the whole string to match, and `[^#\r\n]*` can never cross a newline, so the field can only be found if it sits on line 1 of the file. Fix by regexing each line independently. Assisted-by: Claude Sonnet 5 --- pkgs/servers/klipper/klipper-flash.nix | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/servers/klipper/klipper-flash.nix b/pkgs/servers/klipper/klipper-flash.nix index b5ce5813a752..3da22fbb448f 100644 --- a/pkgs/servers/klipper/klipper-flash.nix +++ b/pkgs/servers/klipper/klipper-flash.nix @@ -17,9 +17,11 @@ let field: with builtins; let - matches = match ''^[^#\r\n]*${field}="([a-zA-Z0-9_]+)".*$'' (readFile firmwareConfig); + lines = lib.splitString "\n" (readFile firmwareConfig); + matchLine = line: match ''${field}="([a-zA-Z0-9_]+)".*'' line; + matched = lib.findFirst (line: matchLine line != null) null lines; in - if matches != null then head matches else null; + if matched != null then head (matchLine matched) else null; matchPlatform = getConfigField "CONFIG_BOARD_DIRECTORY"; matchBoard = getConfigField "CONFIG_MCU"; matchAvrdudeProtocol = getConfigField "CONFIG_AVRDUDE_PROTOCOL";