From c80a145a228631161a16fcbb5edbc6a5171803ad Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Mon, 5 Feb 2024 14:50:14 +0530 Subject: [PATCH 1/4] fix(parser): parse the packages ending with eof --- nix/haskell-parsers/parser.nix | 6 +++++- test/with-subdir/cabal.project | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/nix/haskell-parsers/parser.nix b/nix/haskell-parsers/parser.nix index 7866299d..4d3655e0 100644 --- a/nix/haskell-parsers/parser.nix +++ b/nix/haskell-parsers/parser.nix @@ -25,7 +25,11 @@ in key = parsec.string "packages:\n"; val = parsec.many1 - (parsec.between spaces1 newline path); + (parsec.choice + [ + (parsec.between spaces1 newline path) + (parsec.between spaces1 parsec.eof path) + ]); parser = parsec.skipThen key val; diff --git a/test/with-subdir/cabal.project b/test/with-subdir/cabal.project index d23eab71..1a862c3b 100644 --- a/test/with-subdir/cabal.project +++ b/test/with-subdir/cabal.project @@ -1,2 +1,2 @@ packages: - ./haskell-flake-test + ./haskell-flake-test \ No newline at end of file From f3d415d135e10f01d144eeb47d3de11e755eb523 Mon Sep 17 00:00:00 2001 From: shivaraj-bh Date: Tue, 6 Feb 2024 09:52:48 +0530 Subject: [PATCH 2/4] add testEOF --- nix/haskell-parsers/parser_tests.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nix/haskell-parsers/parser_tests.nix b/nix/haskell-parsers/parser_tests.nix index 0a4121b6..f26e2ad0 100644 --- a/nix/haskell-parsers/parser_tests.nix +++ b/nix/haskell-parsers/parser_tests.nix @@ -17,6 +17,14 @@ let ''; expected = [ "foo" "bar" ]; }; + + testEOF = { + expr = eval '' + packages: + foo + bar''; + expected = [ "foo" "bar" ]; + }; }; cabalExecutableTests = let From eb5bab1eadbb12d629b119390dee041cbc81666d Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Tue, 6 Feb 2024 02:55:06 -0500 Subject: [PATCH 3/4] Update parser_tests.nix --- nix/haskell-parsers/parser_tests.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nix/haskell-parsers/parser_tests.nix b/nix/haskell-parsers/parser_tests.nix index f26e2ad0..4b9fcf49 100644 --- a/nix/haskell-parsers/parser_tests.nix +++ b/nix/haskell-parsers/parser_tests.nix @@ -18,6 +18,7 @@ let expected = [ "foo" "bar" ]; }; + # Handles cases where cabal.project does not end with newline testEOF = { expr = eval '' packages: From 9a7c8d25161033ae5b26f3570292d3877d173c41 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar <3998+srid@users.noreply.github.com> Date: Tue, 6 Feb 2024 02:55:55 -0500 Subject: [PATCH 4/4] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d749878..799ba052 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - #210: Add `extraLibraries` to `settings` module. - #215: Improved debug logging. - #216: Remove `debug` option (pass `--trace-verbose` to nix instead) +- #222: Improve `cabal.project` parser by handling files not ending with newline - Breaking changes - #221: Switch to `buildFromSdist`, to allow using non-standard package sets (wherein `cabal-install` is otherwise built without using user's overrides)