From 46de57d535c660a90abf80355bf1c84943aa4fd6 Mon Sep 17 00:00:00 2001 From: Hamish Mackenzie Date: Tue, 24 Sep 2024 13:00:28 +1200 Subject: [PATCH] Trim trailing whitespace parsing cabal.project Fixes #2252 --- lib/cabal-project-parser.nix | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/cabal-project-parser.nix b/lib/cabal-project-parser.nix index 05fcdce642..52df997b6d 100644 --- a/lib/cabal-project-parser.nix +++ b/lib/cabal-project-parser.nix @@ -46,6 +46,8 @@ let let # Look for a new attribute name pair = builtins.match "([^ :]*): *(.*)" s; + trim = x: let m = builtins.match "(.*[^ \t])[ \t]*" x + in pkgs.lib.optionalString (m != null) (builtins.head m); # Function to build the next parse state when the attribute name is known nextState = name: value: { @@ -62,7 +64,7 @@ let if pair != null then # First line of a new attribute - nextState (builtins.head pair) (builtins.elemAt pair 1) + nextState (builtins.head pair) (trim (builtins.elemAt pair 1)) else if name != null then nextState name s # Append another line to the current attribute