From feaaf56e5489c0aec9508084fc15b0b5a097ba9f Mon Sep 17 00:00:00 2001 From: derped Date: Sat, 18 May 2024 11:14:54 +0200 Subject: [PATCH] Correctly handle lua conversion for empty lists. --- pkgs/luaUtils.nix | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkgs/luaUtils.nix b/pkgs/luaUtils.nix index 490d5c9..51605d6 100644 --- a/pkgs/luaUtils.nix +++ b/pkgs/luaUtils.nix @@ -70,15 +70,18 @@ let listToLua = list: assert builtins.isList list; - let - wrap = (lib.elemAt list 0) != "__unpack"; - strippedList = if wrap then list else (lib.drop 1 list); - in - lib.concatStrings [ - (optionalString wrap "{") - (concatStringsSep "," (map toLua strippedList)) - (optionalString wrap "}") - ]; + if list != [ ] then + let + wrap = (lib.elemAt list 0) != "__unpack"; + strippedList = if wrap then list else (lib.drop 1 list); + in + lib.concatStrings [ + (optionalString wrap "{") + (concatStringsSep "," (map toLua strippedList)) + (optionalString wrap "}") + ] + else + "{}"; /** Converts a nix set into its Lua representation.